Creating an array of default-constructed class instances

Simon none at example.org
Sat Feb 9 23:40:41 PST 2013


On Sunday, 10 February 2013 at 06:57:42 UTC, Ali Çehreli wrote:
> On 02/09/2013 10:52 PM, Ali Çehreli wrote:
>
> >   auto things = iota(10).map!(i => new Thing(i))().array;
>
> Actually, without the extra parentheses:
>
>     auto things = iota(10).map!(i => new Thing(i)).array;
>
> Ali

It's a shame there isn't any simple syntax for it, but that's 
some neat and flexible code.

Thanks!


More information about the Digitalmars-d-learn mailing list