Error: variable 'xyz' has scoped destruction, cannot build closure

Paul Backus snarwin at gmail.com
Fri Oct 5 16:34:32 UTC 2018


On Friday, 5 October 2018 at 06:56:49 UTC, Nicholas Wilson wrote:
> On Friday, 5 October 2018 at 06:44:08 UTC, Nicholas Wilson 
> wrote:
>> Alas is does not because each does not accept additional 
>> argument other than the range. Shouldn't be hard to fix though.
>
> https://issues.dlang.org/show_bug.cgi?id=19287

You can thread multiple arguments through to `each` using 
`std.range.zip`:

     tenRandomNumbers
         .zip(repeat(output))
         .each!(unpack!((n, output) => 
output.appendln(n.to!string)));

Full code: https://run.dlang.io/is/Qe7uHt


More information about the Digitalmars-d-learn mailing list