This one weird trick allows you to capture loop variables.

Timon Gehr timon.gehr at gmx.ch
Sun Oct 20 22:36:21 UTC 2024


On 10/20/24 20:14, Sebastiaan Koppe wrote:
> 
> Nowadays I dislike them because they allocate behind the scene, and you 
> still get this odd foreach behavior mentioned here - which, to be fair, 
> however unintuitive, I believe to be correct given the interplay of 
> features.

The odd `foreach` behavior is a long-standing compiler bug.
The behavior with `opApply` is indeed the only correct behavior, no 
interplay of features has to be considered.


More information about the Digitalmars-d mailing list