function ... end
Try it yourself →Defines your own command.
Syntax
function name(params) ... return ... end
Description
Defined with function, closed with end. return yields the result (the last expression is also automatically returned). Global is not needed inside functions.
Example
function square(x)
return x * x
end
println(square(5))Expected output
25
When to use?
Preventing code repetition, breaking the program into parts.