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
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