Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can someone explain the return statement to me?

Asked by 8 years ago

i've watched several videos and read all the wiki articles about it but still doesnt make sense

1 answer

Log in to vote
3
Answered by 8 years ago
Edited 8 years ago

Address

You can think of this return statement the same way in real life. Say for example, a company sends you a package that you don't want. Them sending you that package is the initial function call, and you returning it to them is what they get back from you. This exact same logic applies in programming as well. Here's an example:

-- A function called "GetSomeValue"
local function GetSomeValue()

    -- Returns a string "Some value" to where ever it was called.
    return "Some value"

end

local Value = GetSomeValue() -- Oh hey, it's called right here. So this is where the returned value will end up! 

print(Value) -- > "Some value"

I'd go into more detail, but I already have a video explaining this topic on my channel that you can check out here. Hope this helped, let me know if you have any questions!

0
thanks so much!! your vid helped me a TON trashtalked 5 — 8y
Ad

Answer this question