Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Loops Ruby Loops Loop Conditionals

Wrong number of arguments

def get_answer(answer) answer = "" print "Type in the letter you need" answer = gets.chomp loop do if answer == "e" puts "You are awesome!" break end end end

answer = get_answer() puts "Hi #{answer}"

I've declared my variable, I'm not sure what/where the problem is.

loop.rb
def get_answer(answer)
answer = ""
print "Type in the letter you need"
answer = gets.chomp
    loop do
      if answer == "e"
        puts "You are awesome!"
    break
  end
end
end

answer = get_answer()
puts "Hi #{answer}"

1 Answer

Hi Erik,

You don't need to write the get_answer method yourself. The challenge mentions that you can assume it already exists.

You only need to write the loop which is going to use the get_answer method.

You can call the get_answer method and assign the value to your answer variable. Then you would check if it's equal to 'e' and break if it is.

Putting that together, you should have something like:

loop do
  answer = get_answer()
  if answer == 'e'
    break
  end
end