7. lets learn to return


Well, I tried a few things and the code either doesn't work or it gives me this. Please help!


Oops, try again. It looks like your add method doesn't return the result of adding two numbers together.

Replace this line with your code. 
def add(a, b)
    return (a + b[0])

puts "Enter two numbers please!  "
num1 = gets.chomp
num2 = gets.chomp
output = add(num1, num2)
puts "Well it isn't my fualt you'r too lazy to do math, but the answer is: " + output


Am I being ignored, or is the Ruby community smaller than the Javascript community?


I highly doubt you are being ignored. I believe Ruby is smaller than Javascript so it might takea little longer for a moderator or help desk person to answer your question. Even in Javascript I sometimes have to wait a little bit so just be patient and someone will help you out soon! :smiley:


def add(a,b)
return a+b

the question is kind of weird...
i find myself going back to older posts to look for help. a lot of people have asked the same questions as others before them.


I noticed that some of the people aren't even using a code that resembles this, making it hard to really figure out what is wrong. :unamused:


RE-EDIT: current code

def add (a, b)
return a + b
add (3,4)

According to another post, this should work but it doesn't... This is exactly how I saw it...

(ruby):3: syntax error, unexpected ',', expecting ')'
add (3,4)


I finally got it! I think for some reason you need to include puts.... Weird!

def add(a, b)
return a + b

puts add(2, 6)


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