18.Forges an object in the fires of mount ruby


This seems to be as straight forward as can be, but it keeps going wrong. Up until now it has been going great. Now it has screeched to a halt.

Error : "undefined method `+' for nil:NilClass"

class Message
    @@messages_sent = 0
    def initialize(from,to)
        @from = from
        @to = to
        @messages_sent += 1

my_message = Message.new("Herschel","Maryann")

I'm sure it's something simple I'm missing, but what?


How about, your second instance of @messages_sent should be @@messages_sent -- thanks, google search outside of this site :slight_smile:

I guess I should have searched harder before posting this!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.