2020-03-16 07:50:12 +01:00
|
|
|
// This script runs for-loops
|
|
|
|
|
2021-06-07 08:52:45 +02:00
|
|
|
let arr = [1, true, 123.456, "hello", 3, 42];
|
2020-03-16 07:50:12 +01:00
|
|
|
|
2021-06-07 08:52:45 +02:00
|
|
|
for (a, i) in arr {
|
|
|
|
for (b, j) in ['x', 42, (), 123, 99, 0.5] {
|
|
|
|
if b > 100 { continue; }
|
|
|
|
|
|
|
|
print(`(${i}, ${j}) = (${a}, ${b})`);
|
2020-02-23 15:48:46 +01:00
|
|
|
}
|
2020-03-16 07:50:12 +01:00
|
|
|
|
|
|
|
if a == 3 { break; }
|
2020-02-23 15:48:46 +01:00
|
|
|
}
|
2020-03-16 07:50:12 +01:00
|
|
|
//print(a); // <- if you uncomment this line, the script will fail to run
|
|
|
|
// because 'a' is not defined here
|
2020-02-23 15:48:46 +01:00
|
|
|
|
2021-06-07 08:52:45 +02:00
|
|
|
for i in range(5, 0, -1) { // runs from 5 down to 1
|
2020-03-16 07:50:12 +01:00
|
|
|
print(i);
|
|
|
|
}
|