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 Conditionals "if" Statements

Mika Laakso
Mika Laakso
4,222 Points

What is wrong with the code?

It feels like everything is okay. What is missing? And if you could tell me how would you find a solution to this problem if you would not know the answer? Thank you.

program.rb
def check_speed(number)
  if number > 55
    print = "too fast"
  end
  if number < 55
    print = "too slow"
  end
  if number == 55
    print = "speed OK"
  end

2 Answers

It seems you are missing an end statement for the function. Also print is a keyword not a variable, and I think they want you to use puts instead.

Try this:

def check_speed(number)
  if number > 55
    puts "too fast"
  end
  if number < 55
    puts "too slow"
  end
  if number == 55
    puts "speed OK"
  end
end
Mika Laakso
Mika Laakso
4,222 Points

Thank you, Zack. Now it works.

You are welcome