Skip to content
November 28, 2012 / Danii Oliver

If/Else Conitional Shorthand

Easy quick short hand for simple conditional statements:
if a condition is met only do one thing
if(variable == x) doSomething();

syntax -> if () ;

if a condition is met do one thing if not do something else
(variable == x) ? doSomething() : doSomethingElse();

syntax -> () ? : ;

a variable is set to one thing or the other based on a condition
variable = (condition == ‘x’) ? ‘something’ : ‘somethingElse’;

syntax -> x = (y == Z) ? : ;

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: