Methods, Blocks & sorting: Printing out correctly but not passing


#1




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


In the Methods, Blocks, & Sorting within Ruby lesson 17, we start off with the following code:

def welcome
    return "Welcome to Ruby!"
end

print welcome

Our instructions are the following:
01. Change your welcome method definition. Add a single string parameter called name.
02. Remove your puts statement and replace it with return "Hello, #{name}"

with the hint of:
Your method should return something like

"Welcome to Ruby, #{name}!"


I've tried a few different ways and i feel like i keep running into the same road block.

The method below prints correctly but does not pass. Error states the method doesn't include the person's name in it's output

def welcome(x)
    name = "John"
    return "Welcome to Ruby, #{name}!"
end

print welcome(1)

Method below prints correctly but does not pass. Error states the method doesn't include the person's name in it's output

def welcome(x)
puts "What is your name?"
name = gets.chomp
return "Welcome to Ruby, #{name}!"
end
welcome(0)

Method below prints correctly but des not pass. Error states the method doesn't include the person's name in it's output

def welcome(name)
    puts "Name:"
    name = gets.chomp
    return "Welcome to Ruby, #{name}!"
end
welcome(name)

Method below gets the error message states welcome method prints to console instead of return

def welcome(name)
    return "Welcome to Ruby, #{name}!"
end
welcome("John")

I can't seem to figure out what they are looking for in this review lesson.

`


#2

There are no syntax errors in what you posted. Perhaps you posted the wrong code.

If you run into syntax errors, I suggests running the code in another interpreter that offers more verbose error messages (in particular you want a line number)


#3

ARGGH!
Sigh. of course it would work now.


#4

Also, you don't need to "print" a method at the end.
just write the name of the method.