Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Terminology question - "if-else" or "if/else"?

+1
−0

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?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

This post was sourced from https://writers.stackexchange.com/q/33559. It is licensed under CC BY-SA 3.0.

0 comment threads

3 answers

+1
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

This post was sourced from https://writers.stackexchange.com/a/33561. It is licensed under CC BY-SA 3.0.

0 comment threads

+1
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

This post was sourced from https://writers.stackexchange.com/a/33560. It is licensed under CC BY-SA 3.0.

0 comment threads

+0
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »