Are the below statements equivalent?

2018-12-26 Thread Machine Code via Digitalmars-d-learn

Give:

enum Foo { a, b, c, d, e }
Foo f = Foo.c;

Are the below statements equivalent?

switch(f) {
case Foo.a:
case Foo.b:
 doSomething();
break;
   // ...
}

and:

(note the comma in the case)

switch(f) {
   case Foo.a, Foo.b: doSomething(); break;
   // ...
}

I found it in some source code, tested and it does work but is 
this the standard behavior?


Re: Are the below statements equivalent?

2018-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 17:33:13 UTC, Machine Code 
wrote:

Are the below statements equivalent?


Yes, it is defined here:

https://dlang.org/spec/statement.html#switch-statement

(#2 in the list)


Re: Are the below statements equivalent?

2018-12-27 Thread Machine Code via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 18:03:44 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 26 December 2018 at 17:33:13 UTC, Machine Code 
wrote:

Are the below statements equivalent?


Yes, it is defined here:

https://dlang.org/spec/statement.html#switch-statement

(#2 in the list)


Thanks!