Embedded switches?

Sarah Reichelt sarah.reichelt at gmail.com
Mon Sep 21 18:39:17 EDT 2009


On Tue, Sep 22, 2009 at 5:48 AM, Richmond Mathewson
<richmondmathewson at gmail.com> wrote:
> I have to use either:
>
> 1. A multi-case switch statement with many sub-switch statements inside it,
>
> or
>
> 2. A multi-case switch statement with many IF . . . THEN statements inside
> it,
>
> or
>
> 3. Many IF . . . THEN statements with many IF . . . THEN statements inside
> them.
>
> Number 3. is obviously going to slow things down a ton!
>
> Should I choose 1. or 2 ?  and why?


My usual rule is to use "if" for 2 or 3 options and "switch" if there
are more optins.
You can apply that to your embedded decisions also.
I don't think you will notice much speed difference either way, so
concentrate on making readable code that you can understand when you
come back to it in a year's time.

Cheers,
Sarah



More information about the use-livecode mailing list