View source for Module:Road data/util
Jump to navigation
Jump to search
You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
local util = {}
local insert = table.insert
local concat = table.concat
local format = mw.ustring.format
---
-- Add all entries in `arr` into `target`.
-- An error is raised if `overwrite` is not true
-- and any key in `arr` is already in `target`.
function util.addAll(target, arr, overwrite)
if type(target) ~= "table" then
error("target is not a table")
end
for key,value in pairs(arr) do
if overwrite or target[key] == nil then
target[key] = value
else
error("Duplicate key: " .. tostring(key))
end
end
end
000
1:0
Template used on this page:
Return to Module:Road data/util.