Lua功能范围

Dev*_*vyn 1 lua

如果我喜欢这个,我会收到错误.我该怎么办?

local function one()
    local function two()
        local function three()
            callMe() -- got error here
        end
    end
end

local function callMe()
    print ("can't call :(")
end

callMe()
Run Code Online (Sandbox Code Playgroud)

dau*_*tor 6

必须在使用之前声明本地人:

local callMe
local function one()
    local function two()
        local function three()
            callMe() -- got error here
        end
    end
end
function callMe()
    print ("can't call :(")
end
callMe()
Run Code Online (Sandbox Code Playgroud)