Variadic function: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) No edit summary |
|||
Line 286: | Line 286: | ||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
<lang rebol>;------------------------------------------- |
|||
; a quasi-variadic function |
|||
;------------------------------------------- |
|||
variadic: function [args][ |
|||
⚫ | |||
print arg |
|||
] |
|||
] |
|||
; calling function with one block param |
|||
<lang arturo>printAll: @(args){ |
|||
; and the arguments inside |
|||
⚫ | |||
print & |
|||
} |
|||
} |
|||
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 |
three |
||
args: yes |
|||
without attributes |
|||
args: yes! |
|||
with: something</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |