about "with statement"
Idan Arye
GenericNPC at gmail.com
Sun Jun 9 13:42:36 PDT 2013
On Sunday, 9 June 2013 at 19:03:12 UTC, khurshid wrote:
> 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;
> }
Not very useful, as the scope of `b` and `s` is limited to
`with`'s block...
More information about the Digitalmars-d
mailing list