Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Variadic-function/Golo/variadic-function.golo
Normal file
24
Task/Variadic-function/Golo/variadic-function.golo
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env golosh
|
||||
----
|
||||
This module demonstrates variadic functions.
|
||||
----
|
||||
module Variadic
|
||||
|
||||
import gololang.Functions
|
||||
|
||||
----
|
||||
Varargs have the three dots after them just like Java.
|
||||
----
|
||||
function varargsFunc = |args...| {
|
||||
foreach arg in args {
|
||||
println(arg)
|
||||
}
|
||||
}
|
||||
|
||||
function main = |args| {
|
||||
|
||||
varargsFunc(1, 2, 3, 4, 5, "against", "one")
|
||||
|
||||
# to call a variadic function with an array we use the unary function
|
||||
unary(^varargsFunc)(args)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue