Methods, Blocks & Sorting == I am lost!


#1



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


I am really struggling with Methods, Blocks & Sorting for Practice Makes Perfect


Help a sister out!


Replace this line with your code.


#2

Let's take a look at your greeter method.

def greeter(name) >>> 'A method called greeter that takes names as arguments.'
return name = "Jane" >>> 'Don't do this! The argument you give greeter is what the name will be
end

Let's refactor greeter to do what we want now.

def greeter(name)
"Hello #{name}!"
end

Use string interpolation to display the name you gave greeter. Return is implicit.

Let's put our method to work now.

greeter('Jane')
Will output => "Hello Jane"

Hope this helps, I'm happy to get a bit more detailed if need be.


#3

Thanks, but I am still stuck. Why is it asking me to define the method as welcome?


#4

I believe if you just change the name of the greeter method to welcome
i.e.
def welcome(name)
blah
blah

welcome(name)

Very silly. A lot of these lessons and programming in general is going to be very specific attention to detail and instructions.
It can be a bit maddening, however it does get easier.

What is important for now is understanding the syntax. What is a method, a method arguement, etc etc.

I recommend 'Why's poignant guide'
It will teach you proper syntax in a fun way.


#5

Hello,

As fight_dragons (cool name btw) said you need to stick to method names also you forgot the comma in the Return "Hello , #{name}" :sweat_smile:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.