Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 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