multiple cases, one expression

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple cases, one expression

Gamehaxe
Hi Nicolas,

In the AST I notice that it is possible to have an array of cases
for one expession, but how do you generate this from haxe?

eg:

       switch(0)
       {
          case 0:
          case 1: trace("One or zero ?");
       }

Actually maps to the empty expsession.  Now this is
exactly as the doco specifies, but the ml code suggests
there might be other possibilities.

Hugh

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: multiple cases, one expression

Nicolas Cannasse
Hugh Sanderson a écrit :
> Hi Nicolas,
>
> In the AST I notice that it is possible to have an array of cases
> for one expession, but how do you generate this from haxe?

switch(0) {
case 0,1:
        trace("One or zero ?");
}

This was added quite late and should be added to the language reference btw.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org