Are they "if-else statements" or are they "if/else statements"? I'm partial to the latter, but I can see the logic of the former - both "if" and "else" are acting as a unit modifier for the noun "statements" (and so a hyphen is appropriate), whereas a slash (usually) indicates an "or" condition. Thoughts?

  • 1
    That would depend entirely on the definition of the language.
    – Chenmunka
    Jan 31, 2018 at 13:06
  • Can you be more specific?
    – Yoel
    Jan 31, 2018 at 13:06
  • 1
    Assuming you are talking about statements in computer software, the definition of the particular language will state how the statements are to be worded. Therefore any software documentation should follow the language standard.
    – Chenmunka
    Jan 31, 2018 at 13:08
  • Oh, I see what you mean - for a minute, I thought you were referring to English/non-English languages. :) I'm referring to a standard "if x, then y; else z". In my mind, this should be called an "if/else statement", seeing as how the semicolon is in place of an "otherwise".
    – Yoel
    Jan 31, 2018 at 13:18
  • 2
    I think this is a good question actually. It's usually understood in context, but I see "if/else" and "do/while" etc all the time, and that's really not appropriate use of a slash.
    – Scribblemacher
    Jan 31, 2018 at 14:56

3 Answers 3


In this case I think what you want is if...else.

The slash tends to be used to suggest alternatives: yes/no answer. But you are talking about a case where both are present.

The hyphen is used to make a phrase into a word you can talk about. Instances have an is-a relationship to their class. But if and else are not consecutive words in these constructions.

Ellipses are used to indicate elided text. There is other text between if and else, so if...else.


I would approach this be doing the following (in order of preference)

  • If you follow a style guide, consult it.
  • If you are writing about a specific coding language, consult that language's official documentation and see how they refer to that construct. (For example, I just looked in the Lua 5.3 reference and see that it uses repeat–until (with an en dash) to describe that kind of statement, so I would use that format in my own docs about Lua)
  • If neither of the above apply, use "if... else statement" or "if-else statement"—it doesn't matter which, but be consistent with your choice.

As you stated in your question a / is generally a stand in for "or". In my opinion, it is very rarely used correctly for that purpose and is often the result of sloppy prose.


Your logic makes sense -- the hyphen seems to join them together (a unit of if-else statements), the slash often means "or". However, the slash can also show connection between two words. (I might be typing from my home office/guest room.)

In practice, I see if-then-else, if/else and if...else. I'd say choose one and be consistent.

  • 1
    It's kind of like I tell my writers: Be consistent - even if you are wrong, be consistently wrong.
    – Yoel
    Jan 31, 2018 at 16:10
  • Consistency certainly makes it easier to fix if there is a right answer. And sometimes it really is just a style choice, in which case, consistency helps reduce confusion.
    – Sharon M
    Jan 31, 2018 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.