Is lua auto garbage collecting this variable?

*Example Code

local function add(x, y)
    local result = x + y

    return result
end

In this code, is the result variable garbage collected after being returned?

Yes, the result is garbage collected after being returned, provided there are no references to it elsewhere.

2 Likes

Thanks for replying with the answer!

Lua, Python, JavaScript – Garbage-Collected
C, C++ – Manual Management

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.