mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-12-13 17:24:21 +00:00
Changed getiter() to disallow nil
values
This commit is contained in:
parent
976f813de9
commit
886bd43bce
9
lume.lua
9
lume.lua
@ -51,13 +51,12 @@ local iternil = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local getiter = function(x)
|
local getiter = function(x)
|
||||||
if x == nil then
|
if isarray(x) then
|
||||||
return iternil
|
|
||||||
elseif isarray(x) then
|
|
||||||
return ipairs
|
return ipairs
|
||||||
else
|
elseif type(x) == "table" then
|
||||||
return pairs
|
return pairs
|
||||||
end
|
end
|
||||||
|
error("expected table", 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
local iteratee = function(x)
|
local iteratee = function(x)
|
||||||
@ -327,11 +326,13 @@ function lume.concat(...)
|
|||||||
local rtn = {}
|
local rtn = {}
|
||||||
for i = 1, select("#", ...) do
|
for i = 1, select("#", ...) do
|
||||||
local t = select(i, ...)
|
local t = select(i, ...)
|
||||||
|
if t ~= nil then
|
||||||
local iter = getiter(t)
|
local iter = getiter(t)
|
||||||
for k, v in iter(t) do
|
for k, v in iter(t) do
|
||||||
rtn[#rtn + 1] = v
|
rtn[#rtn + 1] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user