Defining a static array with values in a range

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 02:33:25 PST 2015


On Thursday, 22 January 2015 at 09:26:21 UTC, tcak wrote:
>> There are convenient constants defined in std.ascii.
>>
>> import std.ascii;
>> string arr = lowercase ~ uppercase ~ digits;
>>
>> // also 'std.ascii.letters' gives ('A' .. 'Z' ~ 'a' .. 'z')
>
> Well, that's just disguising what we can't do.
>
> D has alot of compile time structures, even much complex than 
> what I asked. So, this type of thing should be doable for 
> immutable arrays.

If you declare the string as immutable, the concatenation will be 
done at compile time.


More information about the Digitalmars-d-learn mailing list