Biggest problems w/ D - strings
Bill Baxter
dnewsgroup at billbaxter.com
Tue Aug 14 16:38:23 PDT 2007
Chris Nicholson-Sauls wrote:
> Jarrett Billingsley wrote:
>> "Deewiant" <deewiant.doesnotlike.spam at gmail.com> wrote in message
>> news:f9rjbi$1sav$1 at digitalmars.com...
>>> Ever since Issue 1268 was fixed in 1.017, you can just write:
>>>
>>> char[32] abc = 0;
>>>
>>
>> I always wished that that were possible, but never knew if it was
>> legal :D
>>
>
> Oh it is, but there's no equivelant one-liner for dynamic arrays.
> Instead you have to:
>
> auto var = new int[len];
> var[] = 42;
>
> Or using Cashew:
>
> import cashew.utils.Array;
> // ...
> auto var = repeat(42, len);
>
> Which is actually just a wrapper around the above example. It'd be nice
> if there were some way to specify an initializor for a dynamic array's
> elements in place, that didn't rely on using a typedef.
>
> typedef int _MyInt42 = 42;
> auto var = cast(int[]) new _MyInt42[len];
>
> o_O
You gonna make that cashew available via dsss net any time soon? If not
you mind if I do it?
--bb
More information about the Digitalmars-d
mailing list