in reply to Re: Re: optimized switch case
in thread optimized switch case

Yes, it gets very unwieldy for larger numbers of options. That is unavoidable if the options are mutually dependent and each combination must give a unique response. That is probably a sign to refactor what the options represent.

If you really have that many distinct choices, chances are they are independent enough to benefit from the treatment suggested by Fastolfe and clintp. The numeric mapping I suggested doesn't need to be used as an array index. An option number can be tested with bitwise operators when logic is needed, and magically masked numbers can be used as hash keys.

After Compline,
Zaxo