Syntactic Sugar for Construction of Empty Dynamic Arrays of a Given Type

"Nordlöw" per.nordlow at gmail.com
Sun Mar 23 10:58:24 PDT 2014


> Ok. Enough for now...but Is there a way to avoid this array 
> special handling:
>
>                 static if (isArray!R)
>                     _range = (D[]).init;
>                 else
>                     _range = R(); // return empty range
>
> through some initializer expression for _range that covers both
>
>     R()
>
> and
>
>     (D[]).init
>
> ?

The answer was right in front of me...

_range = R.init



More information about the Digitalmars-d-learn mailing list