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 Elsif challenge

Kelvin Spencer
Kelvin Spencer
1,742 Points

It seems there is an error, I am typing else if car_speed == speed_limit... and it is not accepting the addition.

car_speed = 55 speed_limit = 55

if car_speed < speed_limit too_fast = false else if car_speed == speed_limit going_speed-limit = true else too_fast = true end

ruby.rb
car_speed = 55
speed_limit = 55

if car_speed < speed_limit
  too_fast = false
else if car_speed == speed_limit
  going_speed-limit = true
else
  too_fast = true
end
Kelvin Spencer
Kelvin Spencer
1,742 Points

updated the following line: going_speed_limit = true , still not processing

a20ff730-5ad3-4da2-92c9-817f291051ae.rb:15: syntax error, unexpected end-of-input, expecting keyword_end

3 Answers

Ack - missed the big one here:

there is no 'else if' in Ruby. It's elsif.

Looks like you're doing this:

going_speed-limit

instead of this:

going_speed_limit

Make sure there's an end statement for the If-elsif-else loop :)

Kelvin Spencer
Kelvin Spencer
1,742 Points

updated the following line: going_speed_limit = true , still not processing

a20ff730-5ad3-4da2-92c9-817f291051ae.rb:15: syntax error, unexpected end-of-input, expecting keyword_end

car_speed = 55 speed_limit = 55

if car_speed < speed_limit

too_fast = false

else if car_speed == speed_limit

going_speed_limit = true

else

too_fast = true

end

Kelvin Spencer
Kelvin Spencer
1,742 Points

Solved: I was typing "else if" instead of "elsif"

Jinx! :) Glad you got it sorted.