Thread overview | |||||
---|---|---|---|---|---|
|
December 26, 2018 Are the below statements equivalent? | ||||
---|---|---|---|---|
| ||||
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? |
December 26, 2018 Re: Are the below statements equivalent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Machine Code | 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) |
December 27, 2018 Re: Are the below statements equivalent? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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!
|
Copyright © 1999-2021 by the D Language Foundation