3 ms·
For others that were wondering what the ?: operator is I found this after a bit of googling: ?: Operator Allows quick retrieval of a non-empty value from 2 val
by shaunxcode 18y ago
For others that were wondering what the ?: operator is I found this after a bit of googling:
?: Operator Allows quick retrieval of a non-empty value from 2 values and/or expressions
$a = true ?: false; // true
$a = false ?: true; // true
$a = 0 ?: 2; // 2
$a = array() ?: array(1); // array(1);
After reflecting on this mutation of the ternary operator I am thinking that the use of something more like !? or ?! or even just ! would make more semantic sense. ?: implies "if this, then that" and what it is doing is "if NOT this then that".