Logo

Programming-Idioms

History of Idiom 7 > diff from v95 to v96

Edit summary for version 96 by Mircea:
New Groovy implementation by user [Mircea]

Version 95

2020-10-21, 10:36:46

Version 96

2020-11-04, 11:51:07

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Variables
i,x,items
Variables
i,x,items
Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
['aaa', 'bbb', 'ccc'].eachWithIndex {
  element, index ->
  println "Item $index = $element"
}
Comments bubble
iterate over a string list