Well, can someone explain to me what the return function in scripts do? Please? :]
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:
01 | function FunctionThatReturns(x) -- Define our function and give it a parameter |
02 | print (x) -- Print "x" to the output |
03 | return x + 1 -- Give back x + 1 |
04 | end |
05 | function FunctionThatDoesntReturn(x) -- Define our other function, also with a parameter |
06 | print (x) -- Output "x" |
07 | end |
08 |
09 | print (FunctionThatReturns( 5 )) --> The function will print "5" then this will print "6" |
10 | print (FunctionThatDoesntReturn( 11 )) --> The function will print "11" then this will print nothing, as nothing was given back. |