8. how i dealt with def greeter


def greeter(name)
    puts "Hello, #{name}"


The instructions insist on using return to display the greeting, but I could not get that to work. Instead, I used puts and it works just fine. This is technically not correct, so how could I get the code to work using return?


been a while since i done ruby, but in general if something is returned, you can either store it in a variable, or print it directly when you call the function:

puts greeter("Sam")

use return in the function. You do understand how return works?


now that you mention it im not too certain on how return works


return does what is says, it returns something. You can see this if you store the result of the function call in a variable:

def greeter(name)
    return "Hello, #{name}"

result = greeter("Sam")
puts result

the returned result is stored in the variable