digitalmars.D.learn - Are the below statements equivalent?
- Machine Code (19/19) Dec 26 2018 Give:
- Adam D. Ruppe (5/6) Dec 26 2018 Yes, it is defined here:
- Machine Code (3/9) Dec 27 2018 Thanks!
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?
Dec 26 2018
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
Dec 26 2018
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:Thanks!Are the below statements equivalent?Yes, it is defined here: https://dlang.org/spec/statement.html#switch-statement
Dec 27 2018








Machine Code <jckj33 gmail.com>