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 Ruby Syntax Method Arguments

say.rb - I don't know what I'm doing wrong

Instructions: Define a method named say. say should take one parameter (name the parameter whatever you want). In the say method body, take the parameter and pass it to puts as an argument. End your program with a call to the say method, and pass the string "Ruby" as an argument.

I've tried so many variations and Google'ing I can't figure out how to fix this error:

Bummer! Your "say" method should take exactly 1 parameter.

def say

puts "Ruby"

end

say

8 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The challenge asks you to define a function that takes one parameter. Currently, your function takes no parameters. Then the function should use puts to put whatever you send in to the screen. However, your code will always print out "Ruby". We want this to be more flexible. We want to print out whatever was sent in.

def say(greeting)
    puts greeting
end

say("Hi there, Ari!")

In the example above I declared a function named "say" that has one parameter. When I call this function a piece of information will be passed in. I'm sending in the string "Hi there, Ari!". This will be assigned to a local variable named greeting. I then print the value of greeting to the screen.

I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

This makes sooooo much more sense. THANK YOU!

I'm having problems with this challenge too and what you say still makes no sense I even tried to copy what you did and change things to how I thought it should be and still I get errors

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Brent Rainwater It's impossible to help you without seeing what you're trying. I would, however, be interested to know what I've written "makes no sense". You might be better served to post a new question on the forums where a student more knowledgeable or helpful than myself can assist you :sparkles:

def say name
  puts "Ruby"
end

say ("Ruby")

this is what I'm working on. I have tried everything I know how to do and still nothing. Ive even watched the videos twice and it seems as if Im doing things right but still get errors

Moderator edited: added markdown to the post so that code renders properly in the forums.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You're really close, here! Also, I meant to post a new question to the forum instead of an answer to this question. But for now, I'm willing to answer here. First, your code lacks a pair of parentheses around the name parameter. Also, your code will also always print out "Ruby". What if we wanted it to print out "Java" instead? We want this to print out whatever we tell it to print out from the call site. The "call site" is the last line. It's the line that says to execute the function with this piece of information being sent in:

def say(name)  #note the parentheses here, whatever is sent in will be assigned to the variable name
    puts name    #print out the value of the variable name
end

say("Brent")  #call the function and send in "Brent". When the function runs, the variable name will have the value "Brent" and that is what is displayed.

Hope this helps! :sparkles:

it did - Thank you - Thank you very much!!!

Nadia Masiero
Nadia Masiero
3,468 Points

I'm having the same problem too. Could you brief me on how you figured this out? The error, Bummer: We couldn't find a method named "say". Did you define one?

say.rb
def say (Ruby)
  puts Ruby
end
say ("Ruby")
Infobahn Pirate
Infobahn Pirate
3,025 Points

This code works.

def say(say) puts say end say("Ruby")

Boby Vilayvong
Boby Vilayvong
13,039 Points

Hi, this worked for me!

def say_hi puts ("hi") end

say_hi

Zachary Scott
Zachary Scott
1,650 Points

Spoiler Alert

def say(zach) 
  puts(zach)
end

say("Ruby")
Fradely Dilone
Fradely Dilone
24,037 Points

def say(argument) puts(argument) end

say("Ruby") // here is where you need to put "Ruby" in order the argument to take that value. :)

Remember no SPACES

Fradely Dilone
Fradely Dilone
24,037 Points
def say(argument) puts(argument) end

say("Ruby") // here is where you need to put "Ruby" in order the argument to take that value. :)

//Remember no SPACES