Top "Foreach" questions

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

forEach vs forEachOrdered in Java 8 Stream

I understand that these methods differ the order of execution but in all my test I cannot achieve different order …

java foreach java-8 java-stream
Qt: is removing QList elements while iterating using foreach macro possible?

I'm new to Qt and trying to learn the idioms. The foreach documentation says: Qt automatically takes a copy of …

c++ qt foreach qlist
Does foreach() iterate by reference?

Consider this: List<MyClass> obj_list = get_the_list(); foreach( MyClass obj in obj_list ) { obj.property = 42; } Is …

c# reference foreach
String replace all items in array PHP

I would like to do a string replacement in all items in an array. What I have is: $row['c1…

php string replace foreach str-replace
Cannot assign void to an implicitly-typed local variable with var and foreach

I'm trying to list all buttons name from my form to list with code var v = new List<Form1&…

c# foreach lambda var
success callback after knockout.js finishes rendering all the elements

I have implemented a knockout foreach binding, with multiple templates in the same page, one of the example is given …

jquery foreach knockout.js
Smarty - foreach loop 10 times and stop

Im using the following Smarty code: {foreach from=$entries key=i item=topic} {if $topic.topic_style == question} <li&…

foreach smarty
Performance difference for control structures 'for' and 'foreach' in C#

Which code snippet will give better performance? The below code segments were written in C#. 1. for(int counter=0; counter<…

c# performance for-loop foreach
PHP - If/else, for, foreach, while - without curly braces?

Something that really would like to know but never found out are shortcuts in PHP. I am currently coding a …

php if-statement foreach curly-braces
Did Delphi ever get a for each loop?

I've read that Delphi was supposed to get a for each loop in Delphi 9. Did this functionality ever make it …

delphi delphi-2009 foreach