Quote:
Originally Posted by JkWhoSaysNi
Why doesn't this work:
variable ? function() : function2();
yet this does:
x = variable ? function() : function2();
The first example never gets processed. It's easier and neater than using
if (var) {
function();
}
else {
function2();
}
|
I recommend you don't use the ternary operator for anything aside from simple substitutions. eg... (x>1? 0 : 1)
Its a very bad programming practice to use it as flow-control. It's not intended for that.