From: Michael Guterl Date: 2007-03-18T00:43:29+09:00 Subject: Re: attr_accessor question ------=_Part_100425_10066691.1174146201761 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 3/17/07, Corey Konrad <0011@hush.com> wrote: > > 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 ArgumentError: wrong number of arguments (0 for 2) Your Animal.new is expecting you to pass in color and size. animal = Animal.new("brown", "big") 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 > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_100425_10066691.1174146201761--