about "with statement"

khurshid khurshod.normuradov at gmail.com
Sun Jun 9 12:03:11 PDT 2013


On Sunday, 9 June 2013 at 11:11:47 UTC, bearophile wrote:
> khurshid:
>
>> D language have like Pascal/Delphi  "with statement",  which 
>> very useful for writing readable code.
>
> It's a quite useful statement, especially with enumerations or 
> associative array literals, to avoid repeating many times their 
> name:
>
> switch (en) with (MyEnum) {
>   case foo: ...
>   case bar: ...
> }

It's very good example!!

And, May be, this is'not bad, too :))

struct C
{
    alias byte  B;
    alias short S;
};

with(C)
{
    B b;
    S s;
}



More information about the Digitalmars-d mailing list