Skip to main content

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
1 vote
0 answers
134 views

Designing conditional compilation blocks

ECMAScript and C have a totally different nature. Certain syntactic features are cryptic in C and don't fit exactly into ECMAScript dialects. For example, I don't think the following: ...
Hydroper's user avatar
  • 1,017
19 votes
10 answers
4k views

Are there any languages where conditions are not first-class expressions?

Novices writing in mainstream languages often don't realise that conditions like x < y are expressions which can occur anywhere an expression is syntactically ...
CPlus's user avatar
  • 8,301
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 ...
CPlus's user avatar
  • 8,301
4 votes
9 answers
1k 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: ...
чистов_n's user avatar
12 votes
2 answers
495 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
17 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,619