Convert output range to input range

Dukc ajieskola at gmail.com
Sat Mar 17 06:58:04 UTC 2018


On Friday, 16 March 2018 at 08:07:09 UTC, Jonathan M Davis wrote:
> For instance, std.array.Appender is an output range, and you 
> get a dynamic array out of it, which would be an input range. 
> So, if you have control over what output range you're dealing 
> with, the simplest would be to just use Appender.

I think it's worth warning that appending on an array may 
invalidate all copies of it. Meaning that you should not append 
on an array while you're iterating over it, unless iterating by 
the original copy of the array. Note that foreach loop copies the 
range by default. Pass refRange(*array) to foreach instead.




More information about the Digitalmars-d-learn mailing list