From: Stefano Crocco Date: 2007-03-18T00:42:38+09:00 Subject: Re: attr_accessor question Alle sabato 17 marzo 2007, Corey Konrad ha scritto: > how come this doesnt worh though? > > class Animal > attr_accessor :color > attr_accessor :size > > def initialize(color, size) > @color = color > @size = size > end > end > > animal = Animal.new > animal.color = "brown" > puts "The color of the animal is #{animal.color}" > animal.color = "red" > puts "Now the animal is #{animal.color}" > animal.size = "big" > puts "The size of the animal is #{animal.size}" > > > > thanks Animal.new creates an instance of class Animal and calls its initialize method, with the arguments you passed to new. Animal#initialize requires two arguments, so you must pass two arguments to Animal.new. For example: animal=Animal.new "green", "little" I hope this helps Stefano