On Monday, 6 May 2024 at 06:29:49 UTC, Liam McGillivray wrote:
This is because the delegate assignment causes the local `card` variable to remain alive. The delegate that's assigned is linked to this variable itself, not the value at the time that the delegate is assigned.

This is https://issues.dlang.org/show_bug.cgi?id=23136. Perhaps it can be fixed in the next edition.

Is there a way I can dereference a variable when placing it in a delegate, so that it's current value is used, rather than the variable itself?

I think you would need to make an array before the loop, assign to an indexed element and use that in the delegate.

Reply via email to