T
Thiago
I'm a noob, trying to learn ruby.
I'm following along with the book Programming Ruby, The Pragmatic
Programmer's Guide, which comes with ruby documentation.
Im on chapter, Implementing a SongList Container, doing the code
samples, but i'm getting the following error when trying to run the
code:
18:in `append': undefined method `push' for nil:NilClass
(NoMethodError)
from F:/InstantRails/rails_apps/test/test2.rb:80
I have a SongList class with the following method:
def append(aSong)
@songs.push(aSong)
self
end
and im trying to run the code sample as in the book:
list = SongList.new
list.
append(Song.new('title1', 'artist1', 1)).
append(Song.new('title2', 'artist2', 2)).
append(Song.new('title3', 'artist3', 3)).
append(Song.new('title4', 'artist4', 4))
This doesnt make any sense. I can create the Song object just fine,
but if i try to add it to the array i get this erro.
Can anyone help me please?
I'm following along with the book Programming Ruby, The Pragmatic
Programmer's Guide, which comes with ruby documentation.
Im on chapter, Implementing a SongList Container, doing the code
samples, but i'm getting the following error when trying to run the
code:
18:in `append': undefined method `push' for nil:NilClass
(NoMethodError)
from F:/InstantRails/rails_apps/test/test2.rb:80
I have a SongList class with the following method:
def append(aSong)
@songs.push(aSong)
self
end
and im trying to run the code sample as in the book:
list = SongList.new
list.
append(Song.new('title1', 'artist1', 1)).
append(Song.new('title2', 'artist2', 2)).
append(Song.new('title3', 'artist3', 3)).
append(Song.new('title4', 'artist4', 4))
This doesnt make any sense. I can create the Song object just fine,
but if i try to add it to the array i get this erro.
Can anyone help me please?