function
Try it yourself →Defines a function.
Syntax
function name(p) ... return ... end
Description
Defined with function and closed with end. Returns values with return (can return multiple as well).
Example
function square(x) return x * x end print(square(5))
Expected output
25
When to use?
Preventing code repetition.