2009/8/9 Björn Karlsson <Bjorn.Karlsson@readsoft.com>

The advantages of this approach are that it's short, elegant, and all the logic is locally defined. (It's also quite cool.) However, you must know your audience -- not everyone is comfortable reading and understanding code like this.

Ok, I like this solution, and is the solution that broadly occurred to me when I read the OP - which you beat me to
answering!

However I'm more interested in different takes on  your final comment, "..., you must know your audience...".

I do struggle with this one at work sometimes - I'm generally inclined to write the kind of code you present,
because it's good code, because it's the right solution, and because to do otherwise would be condescending
and patronising to my colleagues. However, I sometimes find myself criticised for writing overly complex
code, and by extension for not being a team player.

Any thoughts?

- Rob.