View Single Post
  #3  
Old 01-23-2007, 01:21 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Quote:
Originally Posted by JkWhoSaysNi View Post
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.
__________________

subliminal message: 1+1=3
Reply With Quote