Re: Switch..Case Statement Question.
John W. Kennedy wrote on 06 mrt 2005 in comp.lang.javas cript:
[color=blue]
> Evertjan. wrote:[color=green]
>> bumbleguppy wrote on 05 mrt 2005 in comp.lang.javas cript:
>>
>>[color=darkred]
>>>You can also try
>>>
>>>switch(true) {
>>>
>>> case(val>1 && val<35): do something;break ;
>>> case(val>=35 && val <53):do something;break ;
>>>[/color]
>>
>>
>> [please quote, usenet is not email]
>>
>> is the above really more useful than:
>>
>> if (val>1 && val<35) do_something;
>> if (val>=35 && val<53) do_something;[/color]
>
> Actually, yes. You're missing an 'else'.[/color]
That being my [inconsequental in this example] mistake
does not per se make it less useful then the switch(true)
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
John W. Kennedy wrote on 06 mrt 2005 in comp.lang.javas cript:
[color=blue]
> Evertjan. wrote:[color=green]
>> bumbleguppy wrote on 05 mrt 2005 in comp.lang.javas cript:
>>
>>[color=darkred]
>>>You can also try
>>>
>>>switch(true) {
>>>
>>> case(val>1 && val<35): do something;break ;
>>> case(val>=35 && val <53):do something;break ;
>>>[/color]
>>
>>
>> [please quote, usenet is not email]
>>
>> is the above really more useful than:
>>
>> if (val>1 && val<35) do_something;
>> if (val>=35 && val<53) do_something;[/color]
>
> Actually, yes. You're missing an 'else'.[/color]
That being my [inconsequental in this example] mistake
does not per se make it less useful then the switch(true)
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Comment