Anonymous user
Call a function: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 4,391:
* If no variable is specified, `put` prints the variable to stdout
<lang sensetalk>put zeroArgsFn()
// Function calls can also be made using the following syntax:
put the zeroArgsFn
function zeroArgsFn
Line 4,399 ⟶ 4,402:
* Running a function requires a keyword such as `put; if no variable is return, put into e.g. _
<lang sensetalk>put TwoArgFn("variable", (3, 4)) into _
// Alternatively, the function can be called like so:
put the TwoArgFn of "variable", (3, 4)
// The parameter list is flexible, allowing any amount of variable to be passed in.
// These can be accessed with the keyword `the parameterList`
// The specified parameters only limits to named parameters
get the TwoArgFn of "variable", (3, 4), "hello"
function TwoArgFn arg1, arg2
Line 4,411 ⟶ 4,418:
* A parameter is set to "" if nothing is specified
<lang sensetalk>
function ThreeArgFn arg1, arg2, arg3
Line 4,418 ⟶ 4,425:
* Using this, default parameter values can be set up if a check if done at the start of the function
<lang sensetalk>
function OneArgFn arg1
Line 4,431 ⟶ 4,438:
* If the argument prefixed by 'container', the variable is passed by reference
<lang sensetalk>put 3 into a
put "Value of a = " & a
// Value of a = 3
put 5 into b
put "Value of b = " & b
// Value of b = 6
|