John John - 2 years ago 72
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download