Originally Posted by zcountezza
Thank you for the excellent information, but I need a bit more clarification:
1) in this example: if (return v0) ? return v1 : return v2; -> is v0 ever returned?
is statement level and is not allowed in expression contexts. However, if you remove the
parts, however, then no,
is never returned. If
evaluates to truthy
will be evaluated and returned, otherwise
will be evaluated and returned.
2) what situations would you use such an example?
In the middle of an expression, where using an if..else
-statement would complicate the code. Or just in any place where you don't need statements in your conditionals.