Switch versus if/then/else ( was: Main menu puzzle, Klaus)

Dave Cragg dcragg at lacscentre.co.uk
Sun Feb 19 05:08:23 EST 2006


On 19 Feb 2006, at 05:27, Judy Perry wrote:

> Yes, but do you think in these terms in day-to-day life?

Well, yes.

When the doorbell rings, I don't think like this:

if it's the postman
   I'll say good morning
if it's the taxman
   I'll get my gun
if it's the neighbor
   etc,

Instead, I'm more likely to think "who could that be", and compile a  
list like this ...

   postman
   milkman
   delivery man

   taxman
   police
   bailiff
   mother-in-law

   daughter's boyfriend

   son's girlfriend's father

...which lends itself to a switch/case structure.

So depending on the situation, both approaches can seem quite natural.

Cheers
Dave



More information about the use-livecode mailing list