ndslice: convert a sliced object to T[]

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 15 01:53:22 PDT 2016


On Wednesday, 15 June 2016 at 08:25:35 UTC, data pulverizer wrote:
> I guess foreach would not copy the elements? for example:
>
> foreach(el; slice.byElement)
> 		x ~= el;
>
> But it feels wrong to be doing work pulling elements that 
> already exists by using foreach. I feel as if I am missing 
> something obvious but can't get it.

The question is: why you need to put them inside an array? If you 
can, leave them in the lazy range and work on it.



More information about the Digitalmars-d-learn mailing list