Foreach loop behaviour and manipulation
Maxim Fomin
maxim at maxim-fomin.ru
Mon Dec 2 07:05:42 PST 2013
On Friday, 29 November 2013 at 00:41:16 UTC, bearophile wrote:
> H. S. Teoh:
>
>> Modifying the loop variable of a foreach is, in general, a
>> risky move.
>
> Right. In my opinion D programmers should learn that this is
> the preferred idiom of using foreach ranged loops:
>
> foreach (immutable i; 0 .. n) {}
>
> Bye,
> bearophile
Unfortunately if you iterate over delegates, this may break
immutability.
See
http://forum.dlang.org/thread/felqszcrbvtrepjtfpul@forum.dlang.org?page=1
More information about the Digitalmars-d-learn
mailing list