Top "Foreach" questions

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

Node.js: for each … in not working

I wanted to use for each ... in with Node.js (v0.4.11). I use it like this: var conf = { index: { path: { …

javascript node.js foreach v8
Iterate over elements of List and Map using JSTL <c:forEach> tag

If I have a JSF backing bean return an object of type ArrayList, I should be able to use <…

list jsp foreach hashmap jstl
"for" vs "each" in Ruby

I just had a quick question regarding loops in Ruby. Is there a difference between these two ways of iterating …

ruby loops foreach iteration each
"continue" in cursor.forEach()

I'm building an app using meteor.js and MongoDB and I have a question about cursor.forEach(). I want to …

javascript mongodb foreach meteor
Java 8 forEach with index

Is there a way to build a forEach method in Java 8 that iterates with an index? Ideally I'd like something …

java for-loop foreach java-8
How do I exit a foreach loop in C#?

foreach (var name in parent.names) { if name.lastname == null) { Violated = true; this.message = "lastname reqd"; } if (!Violated) { Violated = !(name.…

c# foreach
Is there a way to access an iteration-counter in Java's for-each loop?

Is there a way in Java's for-each loop for(String s : stringArray) { doSomethingWith(s); } to find out how often the …

java loops for-loop foreach
JS: iterating over result of getElementsByClassName using Array.forEach

I want to iterate over some DOM elements, I'm doing this: document.getElementsByClassName( "myclass" ).forEach( function(element, index, array) { //do …

javascript foreach getelementsbyclassname
foreach with index

Is there a C# equivalent of Python's enumerate() and Ruby's each_with_index?

c# foreach
PHP foreach change original array values

I am very new in multi dimensional arrays, and this is bugging me big time. My array is as following: $…

php arrays foreach