20/20 Up, Up, and Away... just NOT working


#1

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.

Thank you in advance...


#2

Here's what I had to do in order to fix it... was there a way to fix it without removing the messages_sent stuff from the first Class?

class Message
def initialize(from, to)
@from = from
@to = to
end
end

my_message = Message.new("me", "brother")

class Email < Message
def initialize(from, to)
super
end
end


#3

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


#4

@@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.


#5

class Message

def initialize(form,to)
@form = from
@to = to

end
my_message = Message.new(@from,@to);end

class Email < Messages
def initialize(from, to)
super
end
its not working


#6

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

my_message = Message.new("NB", "JD")

class Email < Message
def initialize(from, to)
super + "hahah" <--------- It worked for me like this.
end
end

but i have no idear what the string dos. Can someone explain?


#7

FYI your superclass is called "Message" but you wrote "MessageS" when trying to pass it to Email

class Email < Messages ((WITH AN S, WHEN IT IS SINGULAR))


#8

Here is what worked for me.

class Message
@@messages_sent = 0

def initialize(from, to)

@from = from
@to = to
  @@messages_sent += 1
end

end

my_message = Message.new("arnold", "Jane")

class Email < Message
def initialize(from, to)
super
end
end

Hope this helps!


#9

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

my_message=Message.new("Eduardo","Fanny")

class Email < Message
    def initialize (from, to) super; end
# ==> one line code    
end

`


#10