27 September 2014

Ifelse shortcut

if (testCondition() && executeMe() || executeMeOtherwise());

Origin come from bash, to execute if else on a single line:
[ $# == 0 ]  && echo 'invalid input' || processInput($*)
If no parameters passed, the echo 'Invalid input' else, start processing the input.


Post a Comment