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 trialkevinthecoder
10,791 PointsElsif statement NOT working at all (it won't turn red when typing it); can't get to the next level because of this.
I need help please! Perhaps you need to reset my system/session/workspace etc. In both the workspace (as I follow along to Jason's video) as well as the Quiz/Challenge portion (task1), the Elseif statement is NOT turning red as I type it and therefore, it is not being executed correctly so that the program/exercise, as well as the Challenge Task, will work correctly. During Jason's exercise and as I type it in the workspace, saving it will NOT work. I am OK with not being able to properly execute the exercise but this is NOT OK for the Challenge portion where the Elseif statement NEEDS to work in order to get past the challenge and proceed with the next section.
I even tried logging out and back in and typed it over. Still doesn't work.
In other worlds, I'M COMPLETELY STUCK. PLEASE HELP. I cannot proceed AT ALL to the next section. Thanks!
car_speed = 55
speed_limit = 55
if car_speed < speed_limit
too_fast = false
elseif
car_speed = speed_limit
going_speed_limit = true
else
too_fast = true
end
Robert Richey
Courses Plus Student 16,352 PointsWhile I can't answer you question as to why, I can sympathize with your frustration. JavaScript uses else if
, Python uses elif
, and of course Ruby's elsif
. All I can say is that Ruby was created by Yukihiro Matsumoto a Japanese computer scientist. The phonics of an Asian language, like Japanese, make more sense when sounding it out as elsif
.
1 Answer
Salman Akram
Courses Plus Student 40,065 PointsHi Kevin
You are almost right but just to have double equal beside elsif in second conditional statement.
car_speed = 55
speed_limit = 55
if car_speed < speed_limit
too_fast = false
elsif car_speed == speed_limit
going_speed_limit = true
else
too_fast = true
end
See example @1:42
kevinthecoder
10,791 Pointskevinthecoder
10,791 PointsI found the problem. I was typing 'Elseif' instead of 'Elsif' (sheepish grin). When creating the Ruby language, why didn't they just keep it as Elseif??? After all, you still have the valid Else command. I'm surprised they didn't change 'Else' to 'Els' . Sigh.