Questions tagged [conditional]

For questions about conditionals, language constructs that enable the execution of specific code based on certain conditions.

Filter by
Sorted by
Tagged with
12 votes
7 answers
1k views

A conditional block with unconditional intermediate code

One problem that is hard to make not at least somewhat repetitive is if there is code that needs to be executed in a certain order, and the intermediate code is unconditional but first and last code ...
user16217248's user avatar
  • 7,525
5 votes
9 answers
808 views

What are pros/cons of ternary conditional operators?

There are some languages that support ternary operator. There are Python, C, JavaScript, PHP. In languages like C and JavaScript, the syntax is like this: ...
nchistov's user avatar
  • 1,589
11 votes
2 answers
411 views

What are some caveats to be careful about when implementing the `?:` (ternary conditional) operator?

Thus far, I see two things that can go wrong when implementing the ?: (ternary conditional) operator: PHP famously incorrectly implemented the ...
FlatAssembler's user avatar
16 votes
15 answers
1k views

What are the syntax options for implementing a ternary "if" operator?

The ternary "if" operator is a syntactic construct for returning one of two values based upon a boolean condition. In most C-family languages its syntax resembles ...
Ginger's user avatar
  • 2,569