2021-06-13 09:50:18 -05:00
|
|
|
owo Pass-by-reference test
|
|
|
|
|
|
|
|
owo Swap two variables.
|
|
|
|
functio swap(left, right) {
|
|
|
|
var tmp = left;
|
|
|
|
left = right;
|
|
|
|
right = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
var foo = "hello";
|
|
|
|
var bar = "world";
|
|
|
|
|
|
|
|
swap(foo, bar);
|
|
|
|
|
2021-06-13 09:53:33 -05:00
|
|
|
if (foo != "world") {
|
|
|
|
"FAILED" print;
|
|
|
|
"foo should be 'world', is actually:" print;
|
|
|
|
foo print;
|
|
|
|
}
|
|
|
|
|
|
|
|
owo AbleScript doesn't have an `else` statement (yet), so we get to
|
|
|
|
owo check the reverse condition.
|
|
|
|
if (foo == "world") {
|
|
|
|
"OK" print;
|
|
|
|
}
|