Module:Array: Difference between revisions
Add more features from Array module in zzz/wuwa wikis |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 127: | Line 127: | ||
-- join as sentence | -- join as sentence | ||
if sentence ~= nil then | if sentence ~= nil then | ||
if #array == 0 then return | if #array == 0 then return '' | ||
elseif #array == 1 then | elseif #array == 1 then result = array[1] | ||
elseif #array == 2 then | elseif #array == 2 then result = array[1] .. sentence_last .. array[2] | ||
else | else | ||
local last = table.remove(array, #array) | local last = table.remove(array, #array) | ||
| Line 139: | Line 139: | ||
-- join with join string | -- join with join string | ||
else | else | ||
result = table.concat(array, join):gsub('{newline}', '\n'):gsub('{space}', ' ')--in case joining string contains keyword | |||
end | end | ||
result = prefix .. result .. suffix | result = prefix .. result .. suffix | ||