Search found 1 match

by jcarballo
Tue Aug 01, 2023 9:51 pm
Forum: Support and Development
Topic: String to access nested table value.
Replies: 8
Views: 7295

Re: String to access nested table value.

Today I came up with this solution:

Code: Select all


a = { b = 2 }

get_nested_value = function(value)
    local ok, _ = pcall(function() return value end)
    return ok and value or nil
end

b = get_nested_value(a.b) -- 2
c = get_nested_value(a.c) -- nil