Hello :)

In FDT for example : cond ? methodA() : methodB() failed :)

The operator cond ? true : false is used to return a value but isn't really
the good solution to launch method i think :)

EKA+ :)


2007/1/26, Steven Sacks | BLITZ <[EMAIL PROTECTED]>:

> does anybody knows if there is any short hand for if
> statement without the else statement?

1. You can remove the braces.

I always use:
if (true) something();

But rarely use:
if (true) something();
else somethingElse();

because it can get lost visually in code.


2. Inline conditional

I use this all the time.
val = (boolean) ? trueVal : falseVal;


3. Inline or conditional

val = (if true) || (if not true)

This one is a little different than the inline conditional.  val will be
set to what is left of the || if what is left of the || resolves true
(i.e. not 0, undefined or null), otherwise it will be set to what's to
the right of the ||.

You can also use these without setting a variable.

// If boolean is true, call funcA, else call funcB.
(boolean) ? funcA() : funcB();

// if funcA returns false, run funcB()
funcA() || funcB();


HTH,
Steven
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to