17 / 19 Methods with Arugments

Hello Wonderful Humans of Code academy!

I have a couple of questions with 17 / 19 as stated in the title and was hoping that you could help!

First off, the instructions for the problem are
Change your welcome method definition. Add a single string parameter called name.
Remove your puts statement and replace it with return “Hello, #{name}”

My code for this problem is:

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

This passes the lesson but honestly confuses me because in the first set of instructions it asks you to “add a single string parameter called name” I was under the impression that strings had to be explicitly within quotation marks leading me to try

def welcome ("name")

for aggggggggggggggggggggggggggggggges!!!

I finally took to these forums and was able to get the assistance I needed from this post (Lesson 17/19 - Methods with arguements)

But, what I don’t quiet understand why it asks for a string; when it is really looking for an argument named (name)
Are string and argument interchangeable phrases?

Finally after entering the code that “passes” me to the next lesson, the box where my code is suppose to print gives the output of:

Shouldn’t it show “Welcome to Ruby,name!”?

Sorry if this is long winded but I don’t want any holes in my foundation of Ruby knowledge.
Thank you for your time

1 Like

I’m not sure about the first part of your question, but the second part the
“Finally after entering the code that “passes” me to the next lesson, the box where my code is suppose to print gives the output of: nil
Shouldn’t it show “Welcome to Ruby,name!”?”
All you did so far was define the method welcome
You still have to call it for it to return something


I was stuck on this too and came to the conclusion that as name is not set to anything you can’t call it.

It’s a very badly done section to be honest. The way to pass it is just to do what you’ve done and not call it, but it doesn’t really make sense in the context of the instructions.

Ruby has no idea what to put in the place of #{name} so it just returns an error. You could fiddle with this but it’s probably not worth it at this point. Very frustrating.


Hey guys I think I got it. This seemed to work for me so hopefully it works for you too.

def welcome(name)
return “Hello, #{name}”


It’s very picky about not having quotes around (name) in the first line and that was what was getting me hung up. I called the name Jerry in the last line.

datasolver79601: For yours I’d just change the return statement to “Hello, #{name}” cause they get weird about writing exactly what the instructions say and just remove the ! from there as well. Then when you call the method take out the def part in the beginning. I don’t really know any of the why for this but it seems to do the trick.


Is this OK?

def welcome (n)
return “Hello,#{n}!”
welcome (“TOM”)

def welcome (name)
return “Hello, #{name}!”
welcome (“Nate”)
#works flawlessly

The instructions are not great in this section. When it asks for a single string parameter, it is asking you to define the method to take a single argument (as you did in the first section of your code). The return statement in your code on line 2 tells Ruby to return a string that contains a string value for the (name) argument. Submitting just this section of code returns nil because you haven’t passed a value to the (name) argument yet; after defining the method (after end on line 3) you need to call the method and pass it an argument. i.e. Line 4 should have:


This calls the welcome method and passes the single string parameter “datasolver79601” and returns: Welcome to Ruby, datasolver79601!