'switch' operator improvement
David Teller
David.Teller at univ-orleans.fr
Tue Oct 16 14:33:59 PDT 2007
Pattern-matching with views [1,2], anyone ?
Cheers,
David
[1] http://martin.jambon.free.fr/micmatch-manual.html#htoc10
[2] http://blogs.msdn.com/dsyme/archive/2006/08/16/ActivePatterns.aspx
On Tue, 2007-10-16 at 20:11 +0200, liorean wrote:
> On 16/10/2007, Peter Hall <peter.hall at memorphic.com> wrote:
> > already you can do something like this:
> >
> > var str;
> > switch(true){
> > case /a/.test(str):
> > alert('a');
> > break;
> > case /b/.test(str):
> > alert('b');
> > break;
> > }
>
> I can only imagine that solution being preferable to chained
> if..else-statements in one case, and that would be if you actually
> used the fall through mechanism. If you don't fall through, it's just
> bloat without any gain.
--
David Teller ------------------------------------------
Security of Distributed Systems -----------------------
Project JStify: Static Analysis for JavaScript 2 -----
-- http://www.univ-orleans.fr/lifo/Members/David.Teller
----- Laboratoire d'Informatique Fondamentale d'Orleans
More information about the Es4-discuss
mailing list