lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I just remembered that Lua 5 introduced the string.gfind function which is a
bit more elegant for this purpose (see previous mail):

-- string form
local function locate(table, path)
    local t = table
    for part in string.gfind(path, "(%w+)") do
        t = t[part]
        if not t then break end
    end
    return t
end

Bye,
Wim