module LoopForEach { @Inject Console console; void run() { val vals = [10, 20, 30, 40]; console.print("Array of values:"); Loop: for (val val : vals) { console.print($" value #{Loop.count + 1}: {val}"); } Map pairs = ["x"=42, "y"=69]; console.print("\nKeys and values:"); for ((String key, Int val) : pairs) { console.print($" {key}={val}"); } console.print("\nJust the keys:"); Loop: for (String key : pairs) { console.print($" key #{Loop.count + 1}: {key}"); } console.print("\nValues from a range:"); for (Int n : 1..5) { console.print($" {n}"); } } }