Call a function: Difference between revisions

no edit summary
(Added examples of implementation)
No edit summary
Line 372:
 
</lang>
 
=={{header|Arturo}}==
 
<lang arturo>printHello {
print "Hello World!"
}
 
sayHello [to]{
print "Hello " + to + "!"
}
 
printAll [args]{
loop args {
print &
}
}
 
getNumber { 3 }
 
// Calling a function that requires no arguments
!printHello
 
// Calling a function with a fixed number of arguments
!sayHello "John"
 
// Calling a function with a variable number of arguments
!printAll #("one" "two" "three")
 
// Using a function in statement context
if true { !printHello }
 
// Using a function in first-class context within an expression
if $(!getNumber)=3 { "yep, it worked" }
 
// Obtaining the return value of a function:
num $(!getNumber)</lang>
 
{{out}}
 
<pre>Hello World!
Hello John!
one
two
three
Hello World!
yep, it worked</pre>
 
=={{header|AutoHotkey}}==
1,532

edits