[Issue 14984] Make it illegal (or at least a warning) to modify the iteration variable in foreach
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 10 09:29:37 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=14984
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |razvan.nitu1305 at gmail.com
Resolution|--- |WORKSFORME
--- Comment #5 from RazvanN <razvan.nitu1305 at gmail.com> ---
Right now, if we modify the element of a foreach range, there is no problem
because we are operating on a copy of the original element. If we need to
modify the actual element, then we need to add ref. That stands true for the
iteration variable also. I don't see why we would deprecate any of this
behavior because it offers maximum flexibility.
--
More information about the Digitalmars-d-bugs
mailing list