Sebastian Hungerecker
12/2/2007 6:38:00 PM
John Sheahan wrote:
> irb(main):011:0> other_wall=Wall.new(10)
> => #<Wall:0xe0371a0 @bottles=10>
> irb(main):012:0>
>
> I'm wondering why I don't get the program to run and count the 99
> bottles of beer starting with 10 in this case?
Because nothing in your initialize method does that.
Wall.new(10) creates a new Wall object and calls its initialize method with
the paramter 10. Since your initialize method is defined as follows:
def initialize(num_of_bottles)
@bottles = num_of_bottles
end
Wall.new(10) will return a Wall object whose @bottles instance variable has
been set to 10. It won't do anything more than that because it hasn't been
told to do anything more.
HTH,
Sebastian
--
NP: The Morningside - The Shadows Of The Past
Jabber: sepp2k@jabber.org
ICQ: 205544826