Variadic function: Difference between revisions

Content added Content deleted
No edit summary
Line 286: Line 286:


=={{header|Arturo}}==
=={{header|Arturo}}==
<lang rebol>;-------------------------------------------
; a quasi-variadic function
;-------------------------------------------
variadic: function [args][
loop args 'arg [
print arg
]
]


; calling function with one block param
<lang arturo>printAll: @(args){
; and the arguments inside
loop args {
print &
}
}


printAll #("one" "two" "three")</lang>
variadic ["one" 2 "three"]

;-------------------------------------------
; a function with optional attributes
;-------------------------------------------
variable: function [args][
print ["args:" args]
if? attr? "with" [
print ["with:" attr "with"]
]
else [
print "without attributes"
]
]

variable "yes"
variable.with:"something" "yes!"</lang>


{{out}}
{{out}}


<pre>one
<pre>one
2
two
three</pre>
three
args: yes
without attributes
args: yes!
with: something</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==