braceless with statements
Dr Machine Code
jckj33 at gmail.com
Fri Nov 12 20:54:49 UTC 2021
On Friday, 12 November 2021 at 20:52:22 UTC, Ali Çehreli wrote:
> On 11/12/21 11:47 AM, Dr Machine Code wrote:
>
>>> Or enums. Enums. ENUMS!!! :)
>>
>> what's wrong with them?
>
> They are great. :) 'with' helps especially with switch
> statements:
>
> enum LongEnumName {
> a, b, c
> }
>
> void main() {
> LongEnumName e;
>
> // 'LongEnumName.' is repeated for each case:
> final switch (e) {
> case LongEnumName.a:
> case LongEnumName.b:
> case LongEnumName.c:
> }
>
> // Same thing but shorter syntax:
> final switch (e) with (LongEnumName) {
> case a:
> case b:
> case c:
> }
> }
>
> Ali
oh I see, I do use that as well. Very helpful ;)
More information about the Digitalmars-d
mailing list