foreach Loop
This lesson explains the foreach loop and how it is used with different data structures in D.
What is the foreach
loop? #
One of the most commonly used statements in D is the foreach
loop. It is used to perform the same operation to every element of a container (or a range).
Operations that are applied to elements of containers are very common in programming. We have seen in the for loop lesson that the elements of an array are accessed with an index value that is incremented at each iteration:
Get hands-on with 1400+ tech skills courses.