Re: [flexcoders] Re: range of values checked in a case (switch)

2010-03-12 Thread Wally Kolcz
Probably clearer, but I grew up learning that if you have more than 2 conditions, better to use a switch/case since it doesn't process the whole condition, it stops when the answer if found. if/elsif/elseif/elseif/elseif/elseif/else is bad practive! Every little bit of processing I save helps

Re: [flexcoders] Re: range of values checked in a case (switch)

2010-03-12 Thread Richard Rodseth
I imagined the original poster would end up with a mixture, depending how many ranges he has, and how many individual values: if (..check range...) { } else { switch(..) ... } switch (true) { case expression1: ... case expression2: .. strikes me as odd. But clever! In a

[flexcoders] Re: range of values checked in a case (switch)

2010-03-10 Thread valdhor
Yes. You need to change the expression you are switching on... switch(true) { case age = 0 age = 4: ageGroup = 1; break; } The reason for this: Your case expression returns a true or false value. This does not match the expression in the switch so change the expression in the

Re: [flexcoders] Re: range of values checked in a case (switch)

2010-03-10 Thread Richard Rodseth
That's very creative! But I think an if statement would be clearer... On Wed, Mar 10, 2010 at 6:00 AM, valdhor valdhorli...@embarqmail.comwrote: Yes. You need to change the expression you are switching on... switch(true) { case age = 0 age = 4: ageGroup = 1; break; }

[flexcoders] Re: range of values checked in a case (switch)

2010-03-10 Thread valdhor
Probably. But that's not what he asked for ;-} --- In flexcoders@yahoogroups.com, Richard Rodseth rrods...@... wrote: That's very creative! But I think an if statement would be clearer... On Wed, Mar 10, 2010 at 6:00 AM, valdhor valdhorli...@...wrote: Yes. You need to change the