7. lets learn to return


#1



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

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


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])
end

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


#2

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


#3

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:


#4

def add(a,b)
return a+b
end
add(1,2)

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.


#5

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:

Nooblife

RE-EDIT: current code

def add (a, b)
return a + b
end
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)
^


#6

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

def add(a, b)
return a + b
end

puts add(2, 6)


#7

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