Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Loops-Foreach/Ecstasy/loops-foreach.ecstasy
Normal file
25
Task/Loops-Foreach/Ecstasy/loops-foreach.ecstasy
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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<String, Int> 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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue