Switch..Case Statement Question.

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)
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Sun, 6 Mar 2005
09:33:37, seen in Lee
bumbleguppy said:


Don't be so quick to rule out the possibility that you lack the
experience to understand why the request is reasonable. That's
a really good way to make yourself appear to be spectacularly
ignorant.

Insulting people for making a request whose value you fail to
understand makes you look that much worse.

With the consequence, which probably does need to be spelt out, that the
regular experts will ignore the questions of such posters, confining
themselves to correcting the errors that they make in their responses,
if any, to others.

Whatever suits the convenience of the expert regulars increases the
chances of getting good answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top