Add new example scripts.

This commit is contained in:
Stephen Chung
2021-06-07 20:15:06 +08:00
parent c4b3ad7c7b
commit bed5256e2e
4 changed files with 35 additions and 2 deletions

11
scripts/switch.rhai Normal file
View File

@@ -0,0 +1,11 @@
let arr = [42, 123.456, "hello", true, 'x', 999, 1];
for item in arr {
switch item {
42 => print("The Answer!"),
123.456 => print(`Floating point... ${item}`),
"hello" => print(`${item} world!`),
999 => print(`A number: ${item}`),
_ => print(`Something else: <${item}>`)
}
}