Shortest way to allocate an array and initialize it with a specific value.
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 11 00:57:46 PDT 2015
On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote:
> Another option:
>
> void main()
> {
> auto a2 = new ubyte[5];
But this causes an extra zero-initialization of a2.
> a2[] = 0xAA; // <-- Assign to "all elements"
Is
auto a2 = value.repeat(size).array;
better in this regard?
More information about the Digitalmars-d-learn
mailing list