diff --git a/table.lua b/table.lua index b5c6165..2ee2aaa 100644 --- a/table.lua +++ b/table.lua @@ -18,6 +18,14 @@ function from_iterator(...) return table end +function default(table, value) + return setmetatable(table, { + __index = function() + return value + end, + }) +end + function map_index(table, func) local mapping_metatable = { __index = function(table, key)