Possible to set conditional variable in 1 line
With the exception of the boolean variable, I'm wondering if it's possible to combine the bottom 2 into one statement, so s exists in the current scope
var boolean = (true or false)
boolean ? s = 40 : s = 80;
var boolean = (true or false), s = boolean ? 40 : 80;
Q: I found this code...
A: Then find its author.
That's actually the point of the ternary operator pretty much, to allow you to do what clueful just did.
Last edited by Declan1991; 07-04-2011 at 06:34 PM.
Reason: Beaten to it.
Great wit and madness are near allied, and fine a line their bounds divide.
duh, i feel like an idiot for not thinking of that sooner. Thanks
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread