Storing temp for later use with ranges

Timoses timosesu at gmail.com
Sat Jun 16 06:29:26 UTC 2018


On Saturday, 16 June 2018 at 01:53:15 UTC, DigitalDesigns wrote:
> Does ranges have the ability to store a temp value in a "range 
> like way" that can be used later?
>
> The idea is to avoid having to create temp variables. A sort of 
> range with "memory"

I believe that if the range is a forward range you can use the 
`.save` method to get a copy of the range in its current state.

Take a look at

https://dlang.org/phobos/std_range_primitives.html#isForwardRange

and

https://dlang.org/phobos/std_range_interfaces.html#ForwardRange


More information about the Digitalmars-d-learn mailing list