Is it possible to write a one-line
if then else
statement in a language that supports short-circuiting? It doesn't have to be language specific, just pseudocode.
In case you didn't know, short-circuiting means that a language will evaluate exp1 || exp2 || exp3 || exp4...
(||
is the or
operator) by first executing exp 1
, then if it returns true, execute exp 2
, and so on... However, the moment exp n
returns false, it does not continue evaluating exp n+1
and anything after that.
Aucun commentaire:
Enregistrer un commentaire