Call a function: Difference between revisions

Line 1,824:
::However, it is reasonably common to see a structure used for this. In this example <code>gif.Options</code> is a structure with multiple members which can initialized/assigned by name or omitted (or the whole third argument can just be <code>nil</code>). <lang go> gif.Encode(ioutil.Discard, image.Black, &gif.Options{NumColors: 16})</lang>
* Optional arguments are supported.
::<lang go>package main
 
import "fmt"
Line 1,839:
}</lang>
* Named arguments are supported.
::<lang go>package main
 
import "fmt"
Line 1,878:
::As with C, a pointer can be used to achieve the effect of reference passing. (Like pointers, slice arguments have their contents passed by reference, it's the slice header that is passed by value).
* Go arguments are passed by value or by reference
::<lang go>package main
 
import "fmt"
Line 1,900:
}</lang>
* Partial and Currying is not directly supported.
::However something similar can be done, see [[Partial function application#Go]]
::<lang go>package main
 
import "fmt"
Line 1,927 ⟶ 1,928:
fmt.Println(partial(5)) //prt 18
}</lang>
::However something similar can be done, see [[Partial function application#Go]]
 
=={{header|Groovy}}==
Anonymous user