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 trialKody Dibble
2,554 PointsI'm not sure what I'm doing wrong? Such a simple thing! Defining Ruby Methods.
Trying to define a Ruby Method...
def hey(hello)
puts "hello"
end
2 Answers
William Li
Courses Plus Student 26,868 PointsHello, Kody
- method name needs to be hello
- and it takes 1 argument.
Your code is almost correct, change your method name from hey to hello; and change the name of the argument from hello to something else, because you can't have method and argument sharing the same name. Then your code should work.
def hello(arg)
end
Codye Watson
16,835 PointsHey Kody,
You have an argument that doesn't do anything.
Now if you have:
def hello(hey)
puts hey
end
Then you can put hello("Hello") then it will output "Hello" in the console, but
def hello(hey)
puts "Hello"
end
Doesn't use that hey argument. Arguments are basically like variables you can pass through the function.
-- More information https://www.ruby-lang.org/en/documentation/quickstart/2/