Gang Of Coders
Home
About Us
Contact Us
All Loops Solutions on Gang of Coders
Total of 279 Loops Solutions
For-each over an array in JavaScript
Javascript
Arrays
Loops
Foreach
Iteration
Accessing the index in 'for' loops
Python
Loops
List
How to enumerate an enum
C#
.Net
Loops
Enums
Enumeration
Loop through an array in JavaScript
Javascript
Arrays
Loops
For Loop
Iterate through a HashMap
Java
Loops
Hashmap
Iteration
How do I loop through or enumerate a JavaScript object?
Javascript
Loops
For Loop
Each
JavaScript closure inside loops – simple practical example
Javascript
Loops
Closures
How to iterate over a dictionary?
C#
Dictionary
Loops
Why is printing "B" dramatically slower than printing "#"?
Java
Performance
Loops
For Loop
system.out
Iterate through object properties
Javascript
Loops
Object
How does PHP 'foreach' actually work?
Php
Loops
Foreach
Iteration
Php Internals
How do I break out of nested loops in Java?
Java
Loops
Nested Loops
Why is using "for...in" for array iteration a bad idea?
Javascript
Arrays
Loops
For Loop
Iteration
Looping through the content of a file in Bash
Linux
Bash
Loops
Unix
Io
How to loop through a plain JavaScript object with the objects as members
Javascript
Loops
Traverse a list in reverse order in Python
Python
Loops
Reverse
A for-loop to iterate over an enum in Java
Java
Loops
For Loop
Enums
C# loop - break vs. continue
C#
Loops
Enumeration
What is the difference between range and xrange functions in Python 2.X?
Python
Loops
Range
Python 2.x
Xrange
How to break out of jQuery each loop?
Jquery
Loops
Break
Syntax for a single-line while loop in Bash
Bash
Loops
While Loop
Ways to iterate over a list in Java
Java
Loops
Collections
Iteration
Calling remove in foreach loop in Java
Java
Loops
Iterator
Foreach
What is the most "pythonic" way to iterate over a list in chunks?
Python
List
Loops
Optimization
Chunks
How to find the foreach index?
Php
Loops
Foreach
Looping through array and removing items, without breaking for loop
Javascript
Loops
How do I iterate over a JSON structure?
Javascript
Json
Loops
What's the best way to break from nested loops in JavaScript?
Javascript
Loops
Nested Loops
Break
PHP How to determine the first and last iteration in a foreach loop?
Php
Loops
Foreach
How to iterate over a JavaScript object?
Javascript
Loops
Object
Iteration
Javascript Objects
How to remove elements from a generic list while iterating over it?
C#
List
Loops
Generics
Key Value
Why does this go into an infinite loop?
Java
Loops
Operators
Variable Assignment
Increment
Is there a "do ... while" loop in Ruby?
Ruby
Loops
How do I add a delay in a JavaScript loop?
Javascript
Loops
Sleep
How to avoid "RuntimeError: dictionary changed size during iteration" error?
Python
List
Dictionary
Loops
Is there a better way to run a command N times in bash?
Bash
Loops
do { ... } while (0) — what is it good for?
C
Loops
Iterating over all the keys of a map
Loops
Dictionary
Go
What is the "right" way to iterate through an array in Ruby?
Ruby
Arrays
Loops
Breaking out of nested loops
Python
Loops
Nested Loops
Declaring variables inside loops, good practice or bad practice?
C++
Loops
Variable Declaration
How do I skip an iteration of a `foreach` loop?
C#
.Net
Loops
Loop backwards using indices in Python?
Python
Loops
In Ruby, how do I skip a loop in a .each loop, similar to 'continue'
Ruby
Loops
Syntax
Iteration
How to retry after exception?
Python
Loops
Exception
Try Except
Pythonic way to combine for-loop and if-statement
Python
Loops
If Statement
For Loop
Is recursion ever faster than looping?
Performance
Loops
Recursion
Iteration
Difference between declaring variables before or in loop?
Java
Performance
Loops
Variables
Initialization
Batch script loop
Windows
Loops
Batch File
Is there a way to access an iteration-counter in Java's for-each loop?
Java
Loops
For Loop
Foreach
How do I break out of a loop in Perl?
Perl
Loops
Break
Strict
How to Iterate over a Set/HashSet without an Iterator?
Java
Loops
Set
Hashset
How can I loop through a C++ map of maps?
C++
Loops
Dictionary
Iteration
Idioms
What's the fastest way to loop through an array in JavaScript?
Javascript
Performance
Loops
How to do something to each file in a directory with a batch script
Windows
File
Loops
Batch File
Cmd
Are loops really faster in reverse?
Javascript
Performance
Loops
For Loop
While Loop
How do I loop through a list by twos?
Python
List
Loops
For Loop
Iteration
Syntax of for-loop in SQL Server
Sql
Sql Server
Loops
Tsql
Syntax
Is there a way to loop through a table variable in TSQL without using a cursor?
Sql Server
Tsql
Loops
For every character in string
C++
Loops
For Loop
Character
How to loop through array in jQuery?
Javascript
Jquery
Arrays
Loops
Iteration
How to write loop in a Makefile?
Makefile
Loops
Is there a way to iterate over a range of integers?
Loops
Go
Integer
Range
How do I loop through a date range?
C#
asp.net
Datetime
Loops
How do I apply the for-each loop to every character in a String?
Java
String
Loops
Foreach
Char
How do I step out of a loop with Ruby Pry?
Ruby on-Rails
Ruby
Loops
Exit
Pry
How do you run a command for each line of a file?
Bash
Loops
Line
Does return stop a loop?
Javascript
Loops
Return
Is it possible to implement a Python for range loop without an iterator variable?
Python
Loops
For Loop
Range
"for" vs "each" in Ruby
Ruby
Loops
Foreach
Iteration
Each
`break` and `continue` in `forEach` in Kotlin
Loops
Foreach
Lambda
Kotlin
Speed up the loop operation in R
Performance
R
Loops
Rcpp
R Faq
How to efficiently remove all null elements from a ArrayList or String Array?
Java
Performance
Loops
For Loop
Arraylist
Should try...catch go inside or outside a loop?
Java
Performance
Loops
Try Catch
foreach vs someList.ForEach(){}
C#
.Net
Generics
Loops
Enumeration
Null check in an enhanced for loop
Java
Syntax
Loops
For Loop
JavaScript: Difference between .forEach() and .map()
Javascript
Arrays
Loops
Foreach
How do I count occurrence of unique values inside a list
Python
Arrays
Variables
Loops
Unique
How to loop through an associative array and get the key?
Php
Loops
Associative Array
How can I make sense of the `else` clause of Python loops?
Python
Loops
For Loop
While Loop
Emulating a do-while loop in Bash
Bash
Loops
Do While
In Java, what are the advantages of streams over loops?
Java
Loops
Java 8
Java Stream
How to create an infinite loop in Windows batch file?
Windows
Loops
Batch File
Infinite Loop
How to add an integer to each element in a list?
Python
Loops
Addition
Why does Lua have no "continue" statement?
Loops
Lua
Language Design
How do you create different variable names while in a loop?
Python
Loops
Variables
Check if key exists and iterate the JSON array using Python
Python
Json
Loops
Is there a "do ... until" in Python?
Python
Loops
Twig for loop for arrays with keys
Php
Arrays
Loops
Twig
Looping in a spiral
Algorithm
Matrix
Loops
Spiral
Python: Continuing to next iteration in outer loop
Python
Loops
Is there any overhead to declaring a variable within a loop? (C++)
C++
Loops
Variable Declaration
Loop through a date range with JavaScript
Javascript
Loops
Date
Iteration
Date Range
PHP Foreach Pass by Reference: Last Element Duplicating? (Bug?)
Php
Arrays
Loops
Reference
How to find the most recent file in a directory using .NET, and without looping?
C#
.Net
File
Loops
Last Modified
Optimizing away a "while(1);" in C++0x
C++
Loops
C++11
Language Lawyer
Undefined Behavior
Checking if array is multidimensional or not?
Php
Arrays
Loops
Multidimensional Array
Element
How to loop through key/value object in Javascript?
Javascript
Loops
For Loop
Iteration
Key Value
Loop through a comma-separated shell variable
Shell
Loops
Unix
For Loop
Cut
Python loop counter in a for loop
Loops
For Loop
Python
Why does using from __future__ import print_function breaks Python2-style print?
Python
Python 2.7
Loops
Vim
Python Import
What is the best way to loop through this array in PHP?
Php
Arrays
Printing
Loops
How to loop through a HashMap in JSP?
Java
Jsp
Loops
Hashmap
C# Iterate through Class properties
C#
Properties
Loops
How do you remove an array element in a foreach loop?
Php
Arrays
Loops
Foreach
Javascript efficiency: 'for' vs 'forEach'
Javascript
Loops
For Loop
Foreach
Iterating through a JSON object
Python
Dictionary
Loops
Is the "*apply" family really not vectorized?
R
Performance
Loops
Vectorization
Apply
Numpy how to iterate over columns of array?
Python
Loops
Numpy
Iterating Over Dictionary Key Values Corresponding to List in Python
Python
List
Function
Dictionary
Loops
Iterator Loop vs index loop
C++
Loops
C++11
Indexing
Iterator
How to break out of a loop from inside a switch?
C++
Loops
Syntax
Switch Statement
Break
How to early break reduce() method?
Javascript
Loops
Reduce
Is it faster to count down than it is to count up?
C
Performance
Loops
Why do you have to call .items() when iterating over a dictionary in Python?
Python
Loops
Dictionary
How to split a long array into smaller arrays, with JavaScript
Javascript
Jquery
Arrays
Loops
Check if list<t> contains any of another list
C#
List
Loops
C# 4.0
Subset
How can I escape white space in a bash loop list?
Bash
Loops
Whitespace
Do while loop in SQL Server 2008
Sql Server
Sql Server-2008
Loops
While Loop
Do While
Python : List of dict, if exists increment a dict value, if not append a new dict
Python
Loops
List
Tuples
Can you 'exit' a loop in PHP?
Php
Loops
Iterate through pairs of items in a Python list
Python
List
Loops
Scala downwards or decreasing for loop?
Scala
Iterator
Loops
For Loop
Loop through a Map with JSTL
Map
Loops
Jstl
Check for null in foreach loop
C#
Loops
Foreach
Null
Single Line Nested For Loops
Python
Loops
For Loop
Nested
Nested Loops
How to iterate over array of objects in Handlebars?
Arrays
Loops
Each
handlebars.js
What is the difference between i = i + 1 and i += 1 in a 'for' loop?
Python
Loops
Numpy
Operators
Loop through each row of a range in Excel
Excel
Vba
Loops
Excel 2003
Indexes of all occurrences of character in a string
Java
Loops
Indexing
Character
Iterating through a list to render multiple widgets in Flutter?
Flutter
Loops
Dart
For what value of i does while (i == i + 1) {} loop forever?
Java
Loops
Types
Breaking loop when "warnings()" appear in R
R
Loops
Warnings
Break
Looping through localStorage in HTML5 and JavaScript
Javascript
Html
Loops
Object
Local Storage
Is it safe to delete an object property while iterating over them?
Javascript
Loops
Object
Properties
Angular 2 Cannot find control with unspecified name attribute on formArrays
Loops
Angular
Angular2 Forms
Decreasing for loops in Python impossible?
Python
Loops
For Loop
How can I loop through all rows of a table? (MySQL)
Mysql
Loops
VBA - how to conditionally skip a for loop iteration
Vba
Conditional
Loops
C#: Looping through lines of multiline string
C#
Loops
Multilinestring
Loop through list with both content and index
Python
List
Loops
How to loop through dates using Bash?
Bash
Loops
Date
Equivalent VB keyword for 'break'
vb.net
Loops
Vb6
Exit
Rails: fields_for with index?
Ruby on-Rails
Loops
Fields For
Iterate over two arrays simultaneously in bash
Arrays
Bash
Loops
Can a 'for' loop inside of a 'for' loop use the same counter variable name?
C
Loops
For Loop
Nested
PHP: Can I get the index in an array_map function?
Php
Arrays
Loops
Dictionary
Iteration
Loop through childNodes
Javascript
Loops
Children
Iterating through a golang map
Map
Go
Loops
Creating an array from a text file in Bash
Arrays
Bash
Loops
Scripting
Variable Assignment
How to loop over a Class attributes in Java?
Java
Attributes
Loops
Loop that also accesses previous and next values
Python
Loops
Iteration
Looping through files in a folder Node.JS
Javascript
Arrays
node.js
Loops
Fs
Updating value in iterrow for pandas
Python
Loops
Pandas
Explicit
How can I return something early from a block?
Ruby
Loops
Return
Break
Tell the end of a .each loop in ruby
Ruby on-Rails
Ruby
Loops
Each
Looping through alphabets in Bash
Bash
Loops
For Loop
VB.NET - How to move to next item a For Each Loop?
vb.net
Loops
Extract list of attributes from list of objects in python
List
Loops
Python
More Pythonic Way to Run a Process X Times
Python
Loops
For Loop on Lua
Loops
For Loop
Lua
Why are memcpy() and memmove() faster than pointer increments?
C++
C
Loops
Looping from 1 to infinity in Python
Python
Loops
Counter inside xsl:for-each loop
Xml
Xslt
Loops
Why are we using i as a counter in loops?
Variables
Loops
Naming
How to make for loops in Java increase by increments other than 1
Java
Loops
For Loop
How to render a tree in Twig
Loops
Recursion
Tree
Twig
Python - TypeError: 'int' object is not iterable
Python
Python 3.x
List
Loops
Iterable
How to reverse tuples in Python?
Python
Loops
Iteration
Tuples
How can I iterate over a string by runes in Go?
String
Loops
Go
Rune
Lambda in a loop
Python
Loops
Anonymous Function
When should I call SaveChanges() when creating 1000's of Entity Framework objects? (like during an import)
Entity Framework
Import
Loops
Performance
Savechanges
How can I loop through all subviews of a UIView, and their subviews and their subviews
Iphone
Objective C
Loops
Uiview
Subview
Why does a for loop behave differently when migrating VB.NET code to C#?
C#
vb.net
Loops
For Loop
MySQL: How to insert a record for each result in a SQL query?
Mysql
Sql
Loops
Insert
Creating a list of objects in Python
Python
List
Object
Loops
Is there ever a need for a "do {...} while ( )" loop?
C++
C
Loops
How to break outer loops from inner structures that respond break (loops/switch)
Loops
Nested Loops
Swift
How to concat string + i?
String
Matlab
Loops
For Loop
Octave
Is it bad practice to use break to exit a loop in Java?
Java
Loops
Jvm
Break
Correct way of looping through C++ arrays
C++
Arrays
Loops
C++11
How to for_each through a list(objects) in Terraform 0.12
List
Loops
Object
Foreach
Terraform
Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?
Javascript
Arrays
Loops
Object does not support item assignment error
Python
Django
Loops
Dictionary
How to 'continue' inside a each loop : underscore, node.js
node.js
Loops
underscore.js
For vs. while in C programming?
C
Loops
For Loop
While Loop
Breaking the nested loop
Php
Loops
Nested Loops
While loop with promises
node.js
Loops
Promise
Q
Get iteration index from List.map()
Loops
Dictionary
Indexing
Dart
Flutter
Iterating over arbitrary dimension of numpy.array
Python
Numpy
Loops
Breaking out of a for loop in Java
Java
Loops
For Loop
Break
Endless loop in C/C++
C++
C
Loops
Infinite Loop
How can I break out of two nested for loops in Objective-C?
C
Objective C
Loops
How to break out of multiple loops at once in C#?
C#
Loops
Goto
Break
Django template can't loop defaultdict
Python
Django
Loops
Strange result when removing item from a list while iterating over it
Python
List
Loops
How to iterate through table in Lua?
Arrays
Loops
Lua
Key
Lua Table
Why can't I use foreach on Java Enumeration?
Java
Loops
How to iterate through property names of Javascript object?
Javascript
Loops
Object
skip current iteration
Php
Loops
Looping Over Result Sets in MySQL
Mysql
Loops
Stored Procedures
Database Cursor
do-while loop in R
R
Loops
Repeat
Do While
R Faq
Is there an equivalent to the "for ... else" Python loop in C++?
Python
C++
Loops
For Loop
Break
iterate vector, remove certain items as I go
C++
Data Structures
Vector
Loops
Iterator
Jquery each - Stop loop and return object
Jquery
Loops
Return
Each
Continue in nested while loops
C#
Loops
While Loop
Continue
Ruby: Continue a loop after catching an exception
Ruby
Exception Handling
Loops
How does a for loop work, specifically for(;;)?
Java
Loops
Syntax
For Loop
Iteration
Should I avoid using Java Label Statements?
Java
Loops
Using command line argument range in bash for loop prints brackets containing the arguments
Bash
Command Line
Loops
For Loop
Arguments
Skip over a value in the range function in python
Python
Loops
For Loop
Range
How to have css3 animation to loop forever
Css
Loops
Animation
Keyframe
Forever
Rails: An elegant way to display a message when there are no elements in database
Ruby on-Rails
Ruby
Loops
Iterator
Modifying list while iterating
Python
List
Iterator
Loops
JavaScript loop performance - Why is to decrement the iterator toward 0 faster than incrementing
Javascript
Performance
Loops
Why use a for loop instead of a while loop?
Loops
Coding Style
Control Flow
How to break from nested loops in Ruby?
Ruby
Loops
Nested Loops
What is the difference between "++" and "+= 1 " operators?
C++
Loops
Integer
Auto Increment
Increment
How do I do a "break" or "continue" when in a functional loop within Kotlin?
Loops
Functional Programming
Break
Kotlin
Continue
Recursion vs loops
Recursion
Loops
Continue For loop
Vba
Loops
For Loop
Next
Retry a Bash command with timeout
Bash
Loops
Timeout
Bash scripting, multiple conditions in while loop
Bash
Shell
Loops
While Loop
Elegant way for do ... while in groovy
Loops
Groovy
Do While
Empty loop is slower than a non-empty one in C
C
Performance
Loops
What's the best way to loop through a set of elements in JavaScript?
Javascript
Arrays
Loops
Elements
PHP: How do you determine every Nth iteration of a loop?
Php
Html
Loops
Jquery, checking if a value exists in array or not
Javascript
Jquery
Arrays
Loops
Loop through files in a folder in matlab
Matlab
Loops
File Io
Csv
Iterating over a 2 dimensional python list
Python
Loops
Multidimensional Array
Run command every second in Bash?
Bash
Loops
Doesn't JavaScript support closures with local variables?
Javascript
Loops
Closures
Why should I avoid loops when designing relationships for a database?
Database
Database Design
Loops
Data Modeling
Entity Relationship
Is using a 'goto' statement bad?
C#
Loops
Break
Goto
Looping through rows in a DataView
.Net
Loops
Dataview
Iterate through dictionary values?
Python
Python 3.x
Loops
Dictionary
Key Value
How to stop intense Javascript loop from freezing the browser
Javascript
Jquery
Performance
Loops
Please explain the use of JavaScript closures in loops
Javascript
Loops
Scope
Closures
Iterate a certain number of times without storing the iteration number anywhere
Python
Loops
Range
How to loop over something a specified number of times in JSTL?
Jsp
Loops
Jstl
Subplot for seaborn boxplot
Python
Python 3.x
Loops
Seaborn
Boxplot
How do you loop through a multiline string in Ruby?
Ruby
String
While Loop
Loops
What is the best way to iterate over the lines of a Java String?
Java
String
Loops
How does OpenMP handle nested loops?
C++
Loops
Parallel Processing
Openmp
Python For loop get index
Python
Loops
For Loop
Indexing
How to break outer cycle in Ruby?
Ruby
Loops
Cycle
LINQ: How to skip one then take the rest of a sequence
C#
Linq
List
Loops
Skip
Repeating a function every few seconds
C#
.Net
Loops
Why do some kernel programmers use goto instead of simple while loops?
C
Linux
Loops
Linux Kernel
Goto
Is indexing vectors in MATLAB inefficient?
Arrays
Performance
Matlab
Loops
Vectorization
Loop starting at -1 doesn't print anything
C
Loops
Integer
Sizeof
Negative Number
for expressions versus foreach in Scala
Scala
Loops
Foreach
endforeach in loops?
Php
Loops
Foreach
If Statement
How to make a setInterval stop after some time or after a number of actions?
Javascript
Loops
for or while loop to do something n times
Python
Performance
Loops
For Loop
While Loop
Loop through array of variable names in Less
Loops
Less
Using scientific notation in for loops
C++
Loops
How to break out of nested loops in Go?
Loops
Go
PHP read sub-directories and loop through files how to?
Php
Loops
Directory
Iterating over integer[] in PL/pgSQL
Arrays
Postgresql
Loops
Plpgsql
Postgresql 8.4
Is using labels in JavaScript bad practice?
Javascript
Loops
Label
Nested Loops
Break
What is meant by a number after "break" or "continue" in PHP?
Php
Loops
Breakpoints
Break
Continue
In a "for" statement, should I use `!=` or `<`?
C++
Loops
For Loop
Conditional Statements
Node.js - Using the async lib - async.foreach with object
node.js
Loops
Object
Asynchronous
Node Async
range in jinja2 inside a for loop
Python
Loops
Jinja2
How can "a <= b && b <= a && a != b" be true?
Java
Loops
If Statement
Autoboxing
Incrementing a variable inside a Bash loop
Bash
Shell
Loops
JavaScript flattening an array of arrays of objects
Javascript
Arrays
Loops
Flatten
When to use forEach(_:) instead of for in?
Swift
Loops
Foreach
Sequence
For in-Loop
Best Loop Idiom for special casing the last element
Java
Loops
While Loop
Idioms
Groovy, how to iterate a list with an index
Arrays
List
Groovy
Loops
Sum two arrays in single iteration
Javascript
Arrays
Loops
illegal use of break statement; javascript
Javascript
Loops
Break
Loop Over Array in Javascript
Javascript
Arrays
Loops
For Loop
Foreach
Identifying last loop when using for each
C#
Java
Ruby
Loops
Foreach
Start a loop from 1
Ruby
Loops
How to loop through all elements of a form jQuery
Jquery
Loops
C# Wait until condition is true
C#
Loops
ViewPostIme pointer 1/0
Java
Android
Loops
Spinner