展开表:

local extract
extract = function (t, key, ...)
    -- print("extract key: ", key, type(t), t)

    if not key then
        return t
    end

    if not t then return nil end

    return extract(t[key], ...)
end

table.extract = extract

local t = {
    x = {
        y = {
            z = {1,2,3}
        }
    }
}

print(table.extract(t, "x", "y", "z", 2))