Jump to content

Variadic function: Difference between revisions

no edit summary
No edit summary
Line 286:
 
=={{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 &
}
}
 
printAllvariadic #(["one" "two"2 "three")</lang>]
 
;-------------------------------------------
; 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}}
 
<pre>one
2
two
three</pre>
args: yes
without attributes
args: yes!
with: something</pre>
 
=={{header|AutoHotkey}}==
1,532

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.