![]() The foreach statement in some languages has some defined order, processing each item in the collection from the first to the last. In object-oriented languages, an iterator, even if implicit, is often used as the means of traversal. ![]() This avoids potential off-by-one errors and makes code simpler to read. Unlike other for loop constructs, however, foreach loops usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". foreach is usually used in place of a standard for loop statement. In computer programming, foreach loop (or for-each loop) is a control flow statement for traversing items in a collection.
0 Comments
Leave a Reply. |