mirror of
https://github.com/neovim/neovim.git
synced 2025-12-10 16:42:42 +00:00
feat: add vim.tbl_get (#17831)
vim.tbl_get takes a table with subsequent string arguments (variadic) that index into the table. If the value pointed to by the set of keys exists, the function returns the value. If the set of keys does not exist, the function returns nil.
This commit is contained in:
committed by
GitHub
parent
39af40580a
commit
69f1de86dc
@@ -490,6 +490,12 @@ describe('lua stdlib', function()
|
||||
eq(false, exec_lua("return vim.tbl_isempty({a=1, b=2, c=3})"))
|
||||
end)
|
||||
|
||||
it('vim.tbl_get', function()
|
||||
eq(true, exec_lua("return vim.tbl_get({ test = { nested_test = true }}, 'test', 'nested_test')"))
|
||||
eq(NIL, exec_lua("return vim.tbl_get({}, 'missing_key')"))
|
||||
eq(NIL, exec_lua("return vim.tbl_get({})"))
|
||||
end)
|
||||
|
||||
it('vim.tbl_extend', function()
|
||||
ok(exec_lua([[
|
||||
local a = {x = 1}
|
||||
|
||||
Reference in New Issue
Block a user