2020-03-16 07:50:12 +01:00
|
|
|
// This script defines a function with two parameters
|
|
|
|
|
|
|
|
let a = 3;
|
|
|
|
|
2016-03-02 03:36:46 +01:00
|
|
|
fn addme(a, b) {
|
2020-03-16 07:50:12 +01:00
|
|
|
a = 42; // notice that 'a' is passed by value
|
|
|
|
a + b; // notice that the last value is returned even if terminated by a semicolon
|
2016-03-02 03:36:46 +01:00
|
|
|
}
|
|
|
|
|
2020-05-02 10:23:36 +02:00
|
|
|
print("addme(a, 4) should be 46:");
|
|
|
|
|
|
|
|
print(addme(a, 4));
|
|
|
|
|
|
|
|
print("a should still be 3:");
|
2020-03-16 07:50:12 +01:00
|
|
|
|
|
|
|
print(a); // should print 3 - 'a' is never changed
|