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 trialAndrew Sabato
8,168 PointsWhy is Ruby's Else if statement called elsif but in other languages its else if. (Why the wrong spelling?)
Why is Ruby's Else if statement called elsif but in other languages its else if. (Why the wrong spelling?)
3 Answers
Michael Hulet
47,913 PointsIt's not wrong spelling. It's just what Ruby chose to use. It's an arbitrary decision that the language designers decided to make. That being said, it's generally just the C-style/inspired languages that use else if
, which includes a broad set of languages. For example, JavaScript (a C-inspired language) uses else if
, but Python (which doesn't draw much inspiration from C) uses elif
. In summary, it's not wrong or anything, but it's just what Yukihiro Matsumoto (the creator of Ruby) liked best
Erika Suzuki
20,299 PointsI know right! It's just to make the language "unique" and probably to save a few types on the keyboard. But if I'm going to choose between "elif" (Python) and "elsif" (Ruby), since both are misspelled anyway, I'd choose "elif" since it's shorter.
Randy Eichelberger
Courses Plus Student 787 PointsOn a side note, you can use else if in Ruby, you just need to close it out with an end as opposed to elsif that allows you to skip the end.