Uninitialized class variable in Forge an Object in the Fires of Mount Ruby


#1


Hi everyone. Lisa here. I've been pouring over the forum but I can't seem to figure out what's wrong with my code. It's probably something really small that my eyes are glazing over. Can someone lend a 2nd pair of eyes :slight_smile:


https://www.codecademy.com/en/courses/ruby-beginner-en-MFiQ6/3/3?curriculum_id=5059f8619189a5000201fbcb#


uninitialized class variable @@mesages_sent in Context::Message


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

end

my_message = Message.new("James", "Lisa")


#2

Your code is correct just write in this format because ruby can sometimes be whitespace sensitive. :slight_smile:

class Message
    @@messages_sent = 0
    def initialize(from, to)
        @from = from
        @to = to
        @@messages_sent += 1
    end
end
my_message = Message.new("James", "Lisa")

#3

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