rhai/scripts/for1.rhai

18 lines
394 B
Plaintext
Raw Normal View History

2020-03-16 07:50:12 +01:00
// This script runs for-loops
2020-05-02 10:23:36 +02:00
let arr = [1, 2, 3, 4];
2020-03-16 07:50:12 +01:00
for a in arr {
2020-03-16 07:50:12 +01:00
for b in [10, 20] {
print(a + "," + b);
}
2020-03-16 07:50:12 +01:00
if a == 3 { break; }
}
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-06-27 15:19:53 +02:00
for i in range(0, 5) { // runs through a range from 0 to 4
2020-03-16 07:50:12 +01:00
print(i);
}