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 trialAnuj Nagpal
Courses Plus Student 3,748 PointsUsing the negation operator, reverse the logic in the boolean statement.
Bummer! The going_too_fast
method did not return the correct value.
def going_too_fast?(car_speed, speed_limit) if !(car_speed > speed_limit) return false else return true end end
def going_too_fast?(car_speed, speed_limit)
if !(car_speed > speed_limit)
return false
else
return true
end
end
2 Answers
Salman Akram
Courses Plus Student 40,065 PointsHi Anuj,
You already add negation operation ( ! ) there as far I can see, that's good but your return method are switching from false to true in third and fifth lines. That's why you get errors messages which requires you not to change anything in boolean values except only negation operation.
def going_too_fast?(car_speed, speed_limit)
if !(car_speed > speed_limit)
return true
else
return false
end
end
Annie Scott
27,613 Pointsdef going_too_fast?(car_speed, speed_limit)
if (!(car_speed > speed_limit))
return true
else
return false
end
end
Mateo Sossah
6,598 PointsMateo Sossah
6,598 PointsIf car_speed is NOT greater than speed_limit, going_too_fast? should answer FALSE. Isn't there an error in the compiler on this one?