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 Operators and Control Structures Ruby Control Structures If challenge!

how do I set the too_fast variable

How do I set a variable

ruby.rb
car_speed = 65
speed_limit = 60

too_fast = "true"
if car_speed > speed_limit
  puts too_fast = "true"
end

2 Answers

Not sure exactly what you're asking, but if I've got it right you want to know if you are setting the variable for too_fast correctly? I think for this instance you are okay, but you just don't have a backup for if it is false. Usually if you want to check for working code in an if statement, make your setup variable opposite of what you want so that you are sure it works. For example:

car_speed = 65
speed_limit = 60

too_fast = "false"

if car_speed > speed_limit
  too_fast = "true"
else
  too_fast = "false"
end

puts too_fast

If i get it right you want to display the world "true" when car_speed is greater than speed_limit. Try the code bellow

car_speed = 65
speed_limit = 60
too_fast = false
if car_speed > speed_limit
    too_fast = true
    puts too_fast
end