Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) Ruby Methods Method Arguments: Part 1

Create a method called "hello" that takes one argument.

I dont understand, how to solve thsi?

def hello = (a) (1)

2 Answers

Hi, Sinan the Thinker:

You haven't defined a valid ruby method. You must define a method properly and immediately declare the arguments right after the name

Declaring a method properly in Ruby

You must end your method definition with end.

If you want to do a oneliner, you must end your statements with ; explicitly to then end it with an end to finish your method definition.

Argument

Ruby has a variety of ways of explaining what arguments your method expects, but perhaps the easiest to add them directly after the name of the method *without *characters usually associated with operators as you have such as =:

By convention, you do so with a set of parentheses to mimic other languages that are more struct, but they're optional:

def hello(argument1) 
  puts argument 1
end

# The following method below is the same thing
def hello argument1
  puts argument1
end

I hope this helps!

You want

def hello(a) end

"a" can really be anything, it's just what you are naming your argument. Putting "end" to denote the end of your function is also important.