Re: Elegant way to eliminate large conditional?
Re: Elegant way to eliminate large conditional?
- Subject: Re: Elegant way to eliminate large conditional?
- From: Jonathan Jackel <email@hidden>
- Date: Fri, 03 Jan 2003 23:31:55 -0500
Say you had two pop up buttons with the five items each. You could assign a
tag to each item using powers of 2, e.g., 2, 4, 8,16,32 for one pop up, 64,
128, 256, 512, 1024 for the other. Add the tags. Switch on the result.
Jonathan
on 1/3/03 10:50 PM, Andrew Merenbach at email@hidden wrote:
>
I'm developing a program that includes a unit converter which, among
>
other things, can convert from any one of five temperature scales to
>
any of the other five temperature scales. The code is hard to
>
maintain, unfortunately, as I use a rather long conditional (with
>
multiple sub-conditionals) to determine the "to" and "from" scales.
>
>
Is there some (elegant) way to use a matrix-like setup (a
>
two-dimensional selector or even an array?) that, given two arguments
>
(a range of five numbers, for each of the temperature scales) will
>
execute a different one of 25 equations or selectors?
>
>
Take care,
>
Andrew Merenbach
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.