Saw this recently in code and was surprised that it worked but it's
pretty cool.

a = "foo";
b = "bar";
c = a || b;
trace(c);
-- foo

a = 0; 
// or a = "";
// or a = false;
// or a = null;
// or a is undefined
b = "bar";
c = a || b;
trace(c);
-- bar

It will return b if a is an empty string, false, null, 0 or undefined.

Interesting shortcut.



_______________________________________________
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