Well, can someone explain to me what the return function in scripts do? Please? :]
✓ ANSWER ACCEPTED
Return
1 answer
✓ Accepted answer
I'd say return is, simply put, the function is giving some thing(s) back. The provided links, though, go more in-depth if you would like.
Example:
function FunctionThatReturns(x) -- Define our function and give it a parameter
print(x) -- Print "x" to the output
return x + 1 -- Give back x + 1
end
function FunctionThatDoesntReturn(x) -- Define our other function, also with a parameter
print(x) -- Output "x"
end
print(FunctionThatReturns(5)) --> The function will print "5" then this will print "6"
print(FunctionThatDoesntReturn(11)) --> The function will print "11" then this will print nothing, as nothing was given back.
This discussion is preserved as it was. New answers, comments, and votes are closed.
