Shorthand for default values in Actionscript

Posted by Ben Jackson Sun, 04 Sep 2005 20:46:00 GMT

Just discovered this little nugget of wisdom... my usual way of assigning default values for optional function arguments:

arg1 = (null == arg1) ? arg1 : "default";

Can be reduced to:

arg1 = arg1 || "default";

Not a huge difference, but I do this so often that just not having to type "arg1" twice is a huge time saver, especially for variables like "myInsanelyLongFunctionParameter".

Update: Beware of using this trick with any parameter which might come up with a value of 0 or false, as any such values will evaluate the same as if the parameter were null.

Posted in ,  | no comments | no trackbacks

Under Attack

Posted by Ben Jackson Tue, 30 Aug 2005 21:41:12 GMT

Today was almost 40 degrees celcius today in Rio. For those of you not down with the metric system that's the equivalent of august in New York City.

My house is right next to the rainforest here, and one of the nicest parts about it is the diverse local flora and fauna. The monkeys that inhabit the trees outside our office are a nonstop source of fun and distraction.

Tonight, however, the hidden wrath of mother nature was unleashed in full. As I write this I'm being bitten in about five different places on my body at once. Our fluorescent lamps, as well as our monitors, are coated with bugs.

Ouch. There's another one.

no comments | no trackbacks

No, I would not like fries with that

Posted by Ben Jackson Sun, 28 Aug 2005 20:44:23 GMT

A quote from Andy Bellass of Mother that nicely sums up why I love Amazon:

"I look at those books and those CDs and think, you know what? I would want to read and buy those - and usually I do. Isn't that the most sophisticated marketing out there? It's a brand you have a relationship with."

"But at McDonalds you buy a Big Mac and they say, would you like a large fries, and you think, if I wanted large fries I would have asked for it."

"But here is Amazon doing exactly the same thing - they're trying to get you to buy more products from their store. But they're doing it by understanding exactly what you want."

Via ideasfactory.

no comments | no trackbacks

No one's perfect (not even Amazon)

Posted by Ben Jackson Fri, 26 Aug 2005 23:28:00 GMT

amazon.jpg

$10.05 to $12.36? So much for Super Savings. This is what happens when business people set the pricing rules and programmers get stuck implementing them.

Posted in  | no comments | no trackbacks

Older posts: 1 ... 16 17 18 19