mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Add table.nilget
This commit is contained in:
parent
7a30cc06dd
commit
9f5de0d3a6
15
table.lua
15
table.lua
@ -15,6 +15,21 @@ function set_case_insensitive_index(table)
|
||||
return map_index(table, string.lower)
|
||||
end
|
||||
|
||||
function nilget(table, key, ...)
|
||||
assert(key ~= nil)
|
||||
local function nilget(table, key, ...)
|
||||
if key == nil then
|
||||
return table
|
||||
end
|
||||
local value = table[key]
|
||||
if value == nil then
|
||||
return nil
|
||||
end
|
||||
return nilget(value, ...)
|
||||
end
|
||||
return nilget(table, key, ...)
|
||||
end
|
||||
|
||||
-- Fisher-Yates
|
||||
function shuffle(table)
|
||||
for index = 1, #table - 1 do
|
||||
|
Loading…
Reference in New Issue
Block a user