diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-15 17:14:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-15 17:14:52 +0800 |
commit | 92b00f4e0bb805f2a9076cc89f3cedd37cc4b150 (patch) | |
tree | 9b6869390ecb4b7446320931bf3b46b1c9f05070 /script/utility.lua | |
parent | 8521ec04253fb6367260bfa74ad17e8d5a5e77fb (diff) | |
download | lua-language-server-92b00f4e0bb805f2a9076cc89f3cedd37cc4b150.zip |
fix #950
Diffstat (limited to 'script/utility.lua')
-rw-r--r-- | script/utility.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/script/utility.lua b/script/utility.lua index 66b769f1..6758a47f 100644 --- a/script/utility.lua +++ b/script/utility.lua @@ -23,6 +23,7 @@ local inf = 1 / 0 local nan = 0 / 0 local utf8 = utf8 local error = error +local upvalueid = debug.upvalueid _ENV = nil @@ -721,4 +722,12 @@ function m.stringEndWith(str, tail) return str:sub(-#tail) == tail end +function m.defaultTable(default) + return setmetatable({}, { __index = function (t, k) + local v = default(k) + t[k] = v + return v + end }) +end + return m |