Always makes me think of my favorite C snippet: 

if (attack = true) {
    launch_nukes(); 
}

Well, I have to admit that I'm drawing a blank on all the great use cases I had in mind, and it didn't seem to light any particular fires with the list, so I'd say this isn't a compelling enough story to take anymore time with at the moment.  If a good–and not obscure–example comes to mind, I'll send it out, otherwise, thanks for the feedback!




Shane Green 
www.umbrellacode.com
408-692-4666 | shane@umbrellacode.com

On Mar 27, 2013, at 10:58 PM, Bruce Leban <bruce@leapyear.org> wrote:


On Wed, Mar 27, 2013 at 10:48 PM, Shane Green <shane@umbrellacode.com> wrote:
That's clever: even works for zero because it's returned by or as second false.  Cool.  So I suppose I have to come up with more examples now ;-)  

Actually, on that point, I actually think the seen.added(value)  (with a better name) is quite a bit cleaner than the one using "or".   Clever as it is, I think someone learning the language would flinch when they saw that… :-)

Yes, I suppose it's a bit obscure but you're only going to use it in a case where you value brevity over clarity, right?
 
The C comma operator which always returns the second value, not depending that the first value is false. You can write this in Python as:

    (foo, bar)[1]

or is there some cleaner way to write that?

    #define comma  and False or
    :-)
 
--- Bruce
Latest blog post: Alice's Puzzle Page http://www.vroospeak.com
Learn how hackers think: http://j.mp/gruyere-security