Georgios MavropoulosPro Student 3,176 Points
Can we use range in an "if" statement?
Can we use range to write this code?
def check_speed(speed) if speed < 45 puts "too slow" end if speed > 60 puts "too fast" end if speed == (45..60) puts "speed OK" end end
Steve HunterTreehouse Moderator 56,301 Points
Yep .... here
However, your example doesn't need it as the options are mutually exclusive - there's no need for the last test as the number can only be within the range following the first two tests, so that just needs an
else clause to output