16/19 Review


#1

Not able to solve this one. What am I doing wrong here?

def welcome("Welcome to Ruby!")
puts "#{welcome}"
end

Keeps bombing out with syntax errors. I've tried return "#{welcome}" too, same story.


#2

You're defining a method called welcome, fine.

You give it a parameter which will always be the same ("Welcome to Ruby!"), this is quite weird, because usually the goal of passing parameters to a method is useful because the parameters can change, so giving a static parameter will not accomplish much (and I doubt Ruby allows that anyway).

Then you're asking puts to display a string, which will be the result of the interpolation of the variable welcome, even though welcome is your method, and not a variable.

I suppose what you wanted to accomplish is a welcome method that changes according to the message you give it?

In this case, something like this works:

def welcome sentence
puts "#{sentence}"
end

welcome("yolo")

#3

Figured it out - thank you for your help!