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