Logo

Programming-Idioms

History of Idiom 7 > diff from v125 to v126

Edit summary for version 126 by suren:
[Groovy] check

Version 125

2022-02-13, 18:11:36

Version 126

2022-02-13, 18:12:54

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
indices traverse traversal
Extra Keywords
indices traverse traversal
Code
items.eachWithIndex {
  x, i -> println "Item $i = $x"
}
Code
class test
{
	public static void main (strimg[] args)
	{
		int arr1[] = {1,2,3};
		int arr2[] = {1,2,3};
		if (arrays.equals(arr1,arr2))
		system.out.println("same");
		else
		system.out.println("same");
	}
}
Demo URL
https://groovyconsole.appspot.com/script/5084818014470144
Demo URL
https://groovyconsole.appspot.com/script/5084818014470144