Top "Foreach" questions

foreach is a looping construct that executes a given piece of code for each element in a list/collection/array.

Finding out current index in EACH loop (Ruby)

Possible Duplicate: Automatic counter in Ruby for each? I want to find out the current index while i am in …

ruby foreach
Is there a reason for C#'s reuse of the variable in a foreach?

When using lambda expressions or anonymous methods in C#, we have to be wary of the access to modified closure …

c# foreach lambda scope anonymous-methods
PHP foreach with Nested Array?

I have a nested array in which I want to display a subset of results. For example, on the array …

php arrays foreach nested
PHP - Modify current object in foreach loop

I was wondering if it is possible to edit the current object that's being handled within a foreach loop I'm …

php arrays object foreach
Changing objects value in foreach loop?

In one place i am using the list of string in that case the i am able to change the …

c# loops foreach enumeration
Intelligent way of removing items from a List<T> while enumerating in C#

I have the classic case of trying to remove an item from a collection while enumerating it in a loop: …

c# list foreach enumeration
Using forEach on an array from getElementsByClassName results in “TypeError: undefined is not a function”

In my JSFiddle, I’m simply trying to iterate over an array of elements. The array is non-empty, as the …

javascript foreach
How do foreach loops work in C#?

Which types of classes can use foreach loops?

c# foreach
How to Convert all strings in List<string> to lower case using LINQ?

I saw a code snippet yesterday in one of the responses here on StackOverflow that intrigued me. It was something …

c# linq lambda foreach
JavaScript: Difference between .forEach() and .map()

I know that there were a lot of topics like this. And I know the basics: .forEach() operates on original …

javascript arrays loops foreach