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 Booleans Ruby Booleans Boolean Review

Add an else clause to the if statement which calls the display_car_speed method

The task is as previous. Here is what I did if ..... else display_car_speed() end

However, it said my answer was incorrect :(. I don't know why. Can anyone explain to me ?

Please format the question so the code is easy to read. It's really not clear what your code is here.

2 Answers

Brandon Hartman
Brandon Hartman
8,032 Points

Hopefully this helps you out!!

car_speed = 50

speed_limit = 45

if (car_speed > speed_limit)

flash_car_speed

else

display_car_speed

end

Vladislav Trotsenko
Vladislav Trotsenko
9,291 Points

What the bullshit? Why my solution has not acceptable? Why in some tasks isn't possible to use ternary operator???

car_speed, speed_limit = 50, 45
car_speed > speed_limit ? flash_car_speed : display_car_speed

But if I using ugly code like this, everything is OK???

car_speed, speed_limit = 50, 45

if car_speed > speed_limit
  flash_car_speed
else
  display_car_speed
end