On Thu, 27 Mar 2014 22:23:40 -, Anh Nhan wrote:
Hey guys,
I want to iterate over an array, while adding new entries, and have
those in the iteration loop.
See here: https://gist.github.com/AnhNhan/9820226
The problem is that the foreach loop seemingly only iterates over the
original
Anh Nhan:
Ah, that the foreach caches the entries would make sense.
What does it mean "foreach caches the entries" for you? Foreach
does very little. It is light syntax sugar over a normal for loop.
Bye,
bearophile
On Thursday, 27 March 2014 at 22:23:41 UTC, Anh Nhan wrote:
Hey guys,
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
See here: https://gist.github.com/AnhNhan/9820226
The problem is that the foreach loop seemingly only iterates
over the orig
On Thursday, 27 March 2014 at 22:26:37 UTC, Infiltrator wrote:
On Thursday, 27 March 2014 at 22:23:41 UTC, Anh Nhan wrote:
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
Depending on what you're trying to do, perhaps you would be
better off ju
On Thursday, 27 March 2014 at 22:23:41 UTC, Anh Nhan wrote:
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
Depending on what you're trying to do, perhaps you would be
better off just adding the entries all at once instead of
iterating the arra
Anh Nhan:
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
Don't iterate an array with foreach while you mutate it, even if
you manage to make it work, the code is not clear.
I suggest to use a C-style for loop with an index and specify in
the
Hey guys,
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
See here: https://gist.github.com/AnhNhan/9820226
The problem is that the foreach loop seemingly only iterates over
the original array, not minding the newly added entries.
Does someb