John John - 8 months ago 26
Ruby Question

method is not returning anything

I'm a newbie in Ruby, and could anybody please answer why the following code is not producing any output?:

def method(name)
return "Hello + #{name}"


It's not giving me any result


Which output? It only returns string. You need to print it or something. Replace last method call with:

puts method("Amy")

Then you'll notice you probably don't need that + because you are already adding name as part of string