blob: efd801314690d5fd901802e495898c993f8418f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Functions
=========
The 'FizzBuzz' example gave us an good overview.
== Arguments 'by reference'
We can also pass parameters by reference.
This enables us to change the variable with in the function.
[source,chapel]
./reference.lm
----
str sa( where:ref < str > ) {
print( "in SA ", where, "\n" )
where = "sa"
print( "in SA ", where, "\n" )
}
where: str = "global"
print( "in global ", where, "\n" )
sa( where )
print( "in global ", where, "\n" )
----
Compiling and running would give us:
----
in global global
in SA global
in SA sa
in global sa
----
|