18/20 help


#1

here is my code:
class Message
@@messages_sent = 0
def initialize (from,to)
@from =from
@to = to
@@messages_sent+=1
end
end
my_message = Message.new ("me","you")

it says

(ruby):8: syntax error, unexpected ',', expecting ')'
my_message = Message.new ("me","you")
^
(ruby):8: syntax error, unexpected ')', expecting $end


#2

I believe you need a space inbetween ("me","you") i.e. ("me", "you")


#3

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

Without space in object. Only in paramters in this case. :wink:


#4

the ruby gods forbid space between the calling of a class and its parameters ...

object = class.new(parameter,parameter)

let it be known! lol hope this helps u remember better thats what helps me :sunglasses:


#6

my_message = Message.new(@from, @to) or
my_message = Message.new("from", "to")


#7

if your still having problem, just reset the code and retype the code and also you need to put @@message _sent just above the def....


#8

This code gives me the green - light

class Message; @@messages_sent = 0; def initialize(from, to); @@messages_sent += 1
@from = from; @to = to; end; end; my_message = Message.new("james", "john") :christmas_tree:


#11

Just in case anyone was having issues with this (even though I know this thread is hella old)...

What also worked for me was calling all three parameters (even though it only asked for the "from" and "to" parameter..

Ex:

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","you","they")

Hope maybe someone could use this :slight_smile:


#12

thanks, this helped me a lot