rhai/scripts/if1.rhai

17 lines
308 B
JavaScript
Raw Normal View History

2022-01-20 05:06:36 +01:00
// This script runs if statements.
2020-03-16 07:50:12 +01:00
let a = 42;
let b = 123;
let x = 999;
if a > b {
2020-05-02 10:23:36 +02:00
print("Oops! a > b");
2020-03-16 07:50:12 +01:00
} else if a < b {
2020-05-02 10:23:36 +02:00
print("a < b, x should be 0");
2020-03-16 07:50:12 +01:00
2022-01-20 05:06:36 +01:00
let x = 0; // <- this 'x' shadows the global 'x'
2020-03-16 07:50:12 +01:00
print(x); // should print 0
} else {
2020-05-02 10:23:36 +02:00
print("Oops! a == b");
2021-04-09 16:48:47 +02:00
}