able-script/examples/pass-by-reference.able
Erin e3d49c9c1f Changed variable declaration / assignment and equals syntax:
- `dim <ident> [value];` is now used for declaration
- `<value> =: <assignable>` is used for assignments
- As token `=` doesn't cause any ambiguity now, it can be used for equals operation
2022-04-18 20:34:08 +02:00

24 lines
348 B
Plaintext

owo Pass-by-reference test
owo Swap two variables.
functio swap(left, right) {
dim tmp left;
right =: left;
tmp =: right;
}
dim foo /*hello*/;
dim bar /*world*/;
swap(foo, bar);
if (foo ain't /*world*/) {
/*FAILED*/ print;
/*foo should be 'world', is actually:*/ print;
foo print;
}
if (foo = /*world*/) {
/*OK*/ print;
}