Problem with irb and ruby programming

I’reading “pragmatic programmers guide” on ruby-doc site.
this simple example, written on irb shell,

class Song
@@plays = 0
def initialize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
@plays = 0
end
def play
@plays += 1
@@plays += 1
“This song: #@plays plays. Total #@@plays plays.”
end
end

after to have insert some simple data,
when executed method “play”,
return me that error :
undefined method `+’ for nil:NilClass

why ?
is not possible use operator “+=” ?
I don’t believe that !!
any suggestions ?
thank’s in advance

bye by fellons

so, when I write:

song = Song.new(“She loves you”, “Beatles”, 120)
song2 = Song.new(“Eleanor Rigby”, “Beatles”, 90)
puts song.play
puts song2.play

I get :

This song: 1 plays. Total 1 plays.
This song: 1 plays. Total 2 plays.

which is right, surely?

sr

sorry, I have make a stupid mistake.
please, excuse me :frowning:

bye by fellons