J
John W. Kennedy
Evertjan. said:John W. Kennedy wrote on 06 mrt 2005 in comp.lang.javascript:
Evertjan. said:bumbleguppy wrote on 05 mrt 2005 in comp.lang.javascript:
You can also try
switch(true){
case(val>1 && val<35): do something;break;
case(val>=35 && val <53):do something;break;
[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;
Actually, yes. You're missing an 'else'.
That being my [inconsequental in this example] mistake
does not per se make it less useful then the switch(true)
I once saw, in the real world, in a production program, 100 (yes,
literally 100) mutually exclusive cases IF'ed without a single ELSE.
---
John W. Kennedy
"Those in the seat of power oft forget their failings and seek only the
obeisance of others! Thus is bad government born! Hold in your heart
that you and the people are one, human beings all, and good government
shall arise of its own accord! Such is the path of virtue!"
-- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)