Hi --

On Thu, 21 Apr 2005 Simon.Mullis / equinoxsolutions.com wrote:

> Greeting all,
>
> How about a refreshingly easy question for a change....
>
>
> Really, really basic question I know, but:
>
> class Song
>  attr_writer  :name, :artist, :duration
> end
> => nil
>
> song = Song.new("Blueberry Hill", "Fats Waller", 320)
> =>      ArgumentError: wrong number of arguments (3 for 0)
>        from (irb):24:in `initialize'
>        from (irb):24:in `new'
>        from (irb):24
>
> However....
>
> song = Song.new()
> => #<Song:0x2aab648>
>
> song.name = "Blueberry Hill"
> => "Blueberry Hill"
>
> song.name
> => "Blueberry Hill"
>
> Have I misread / misunderstood the text?  Why the errors?

You have to build up the example cumulatively -- see the #initialize
method on p. 325.  (That's where you tell it to expect 3 args.)


David

-- 
David A. Black
dblack / wobblini.net