|
|
|
< variables |
Local & Global |
private / public > |
|
|
System variables, and most user-defined variables, have global scope, meaning they can be defined in one function (or the main routine) and still used in any other functions. By contrast a local variable is created within a function and destroyed when the function ends. Local variables names begin with a hash #, e.g. #myshape. When you pass parameters to a function, these are also made available as local variables, in an array starting with #_1, #_2, etc // prints "hello, hello, hello, hello, hello" If one function calls another, you can refer to the local values in the previous function call by using two hashes instead of one //prints the fractions 1/5, 2/5 ... Parameters are passed by value, i.e. a copy is made as they are passed. Any changes you make to them do not affect the object they were copied from. If you want to pass by reference, pass an alias. |
|
< variables |
private / public > |