Else If in Popular Programming Languages

Problem Statement

I write program in many languages and the one thing I keep forgetting is how to spell “else if”. OK, stop laughing and think about it: each language spells “else if” differently: else if, elseif, elsif, or even elif.

Solution

To put my mind to rest, I create this list which serves as a quick look-up for me. I am sure that someone else might find this useful.

The Languages

Language Keywords Notes
AWK if, else if, else Just like C/C++.
bash if, then, elif, else, fi The fi keyword ends the if construct.
C/C++/C# if, else if, else Technically, these languages does not have the “else if” keyword, but the effect is the same.
Java/Javascript if, else if, else See note for C
Perl if, elsif, else
Python if, elif, else
Tcl if, elseif, else
Visual Basic If, Then, ElseIf, Else, End If Not case sensitive, but the IDE usually spells as presented

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s