Hey scripters! Just asking a question here!
What does a return do in RLua and when would I need to use it? Can I attach arguments to it?
Hey scripters! Just asking a question here!
What does a return do in RLua and when would I need to use it? Can I attach arguments to it?
A return statement ends a function’s execution and ”return” control to the main program.
If you put a value after return, the value will be the output of the function.
Returns are mainly used for functions, lets say you send a request, the function does a operation and returns a new value.
local function ChangeNumber(Number)
Number = Number*2
return Number, "The New Number"
end
local NewNumber,stringzz = ChangeNumber(12)
print(NewNumber) -- 24
print(stringzz)--"The New Number"
Where you would may use Returns: