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

"Set a variable called "too_fast" equal to "true" if the car_speed is faster than the speed_limit." Why is answer wrong?

My answer was: if car_speed > speed_limit too_fast = "true" end

10 Answers

Use the boolean value true, not a string value "true".

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

And make sure these are 3 separate lines, it won't work as one line.

@Maciej Czuchnowski, not that your answer is wrong, but actually you could do it in one line in Ruby and is still good design. ```ruby : too_fast = true if car_speed > speed_limit

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

I know, I was referring to the code that Juliana showed, with end at the end :)

Carl Sergile
Carl Sergile
16,570 Points
 car_speed = 55speed_limit = 60

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

THIS IS IT.

Roscoe Coney
Roscoe Coney
13,124 Points

type the following:

too_fast = true

Hey I came across this post and none of the answers above worked for me, however the code I typed in below finally worked. Hope that helps someone.

car_speed = 55 speed_limit = 60 too_fast = car_speed > speed_limit

if too_fast puts "true" else puts "false" end

Hey I came across this post and none of the answers above worked for me, however the code I typed in below finally worked. Hope that helps someone.

car_speed = 55 speed_limit = 60 too_fast = car_speed > speed_limit

if too_fast puts "true" else puts "false" end

Hey I came across this post and none of the answers above worked for me, however the code I typed in below finally worked. Hope that helps someone.

car_speed = 55 speed_limit = 60 too_fast = car_speed > speed_limit

if too_fast puts "true" else puts "false" end

ellie adam
ellie adam
26,376 Points

this works

too_fast = true

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

The section is called "control structures", so you were supposed to use an if statement to get that result, assuming that the variable values may be different in the future, n which case your code would fail the expectation.

Jeremy Kerrigan
Jeremy Kerrigan
12,002 Points

This is the answer and I believe it is the structure they want.

car_speed = 65 speed_limit = 60 too_fast = true //Set a variable called "too_fast" equal to "true"

if car_speed > speed_limit //if the car_speed is faster than the speed_limit. puts too_fast end

Nasser Sanou
Nasser Sanou
6,835 Points

This works as well!

car_speed = 55 speed_limit = 60

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

Ben Holland
PLUS
Ben Holland
Courses Plus Student 4,062 Points

if car_speed > speed_limit

too_fast = true

end

That is the answer.