Lua Thoughts

6 thoughts
last posted Feb. 18, 2013, 6:21 p.m.

5 earlier thoughts

0

When you define a function inside another function, if you don't explicitly mark it as "local" it will be assigned to a global variable, i.e.

function b()
    print("goodbye!")
end
function a()
    function b()
        print("hello!")
    end
end
b() -- "goodbye!"
a() -- over-writes b
b() -- "hello!"

This is not a good thing.