Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #10388
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Skip case is not expected |
| Date | Thu, 19 Jan 2012 15:34:24 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 29 |
| Message-ID | <jf964t$7fa$1@dont-email.me> (permalink) |
| References | <aa1b4e7f-7175-476f-b114-f52dbad34b4e@l19g2000yqj.googlegroups.com> <c968f646-614f-4c8d-bdeb-819738fc16cf@18g2000yqe.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 19 Jan 2012 13:34:21 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="ngroV0xYIIv0dzjhyZhv5A"; logging-data="7658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18m9BiCPXvFKwl6To7Ypgtg" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
| In-Reply-To | <c968f646-614f-4c8d-bdeb-819738fc16cf@18g2000yqe.googlegroups.com> |
| X-Antivirus-Status | Clean |
| X-Antivirus | avast! (VPS 120119-0, 19.01.2012), Outbound message |
| Cancel-Lock | sha1:nCjEJr3Nzwpe7acIj9CbNdmVQlA= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:10388 |
Show key headers only | View raw
2012-01-19 15:11, Captain Paralytic wrote:
>> var i = 6; switch (i) {
>> case i< 10:
[...]
> Well what is wrong is that you are making up your own syntax.
Technically, the syntax is correct. This is a matter of misunderstanding
the meanings (semantics).
> switch(i) Says examine the value of i
> case value The values need to be specific values that the value of i
> can be compared with.
So what happens here is that the expressions in case clauses are
evaluated, and whether they evaluate to true or false, none of them
matches the value of i.
> Try replacing switch(i) with switch(true) and put your logical
> expressions in brackets.
Using switch(true) is possible but does not make the code particularly
readable. Good old if statements are easier to read.
I don't see why the expressions would need to be put in brackets, or in
parentheses, in case clauses.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Skip case is not expected Archos <raul.san@sent.com> - 2012-01-19 04:46 -0800
Re: Skip case is not expected Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-19 05:11 -0800
Re: Skip case is not expected "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-19 15:34 +0200
Re: Skip case is not expected Richard Cornford <Richard@litotes.demon.co.uk> - 2012-01-19 05:36 -0800
csiph-web