I’ve checked earlier chapters, the other ‘help’ forum in here… and still can’t figure out why my code isn’t working. I’ve checked, double-checked, and it’s still crashing. “Oops, try again. Did you change Email’s initialize method to accept two parameters, ‘from’ and ‘to’?” Yes, I did, thank you very much.
class Message
@@messages_sent = 0
def initialize(from, to, messages_sent) @from = from @to = to
@@messages_sent += 1
end
end
my_message = Message.new(“me”, “brother”, 1)
class Email < Message
def initialize(from, to)
super
end
end
Insight is welcome, wonderful, and appreciated. This should be working, but I’m still too new to figure out why it is not.
That was the only way I was able to complete the lesson as well… I think omission of the third “messages_sent” parameter (or instructions to delete it) is an error.
It worked after I deleted the following code:
@@messages_sent = 0
the parameter “messages sent” in “initialize(from, to, messages_sent)”
@@messages_sent += 1
@@messages_sent is NOT a parameter and should not have been included in the first place as part of the parameters of the initialize method. It is a class variable.