Skip to content

Commit

Permalink
Merge pull request #1 from Novaly-Studios/ayuka/skip-if-nil
Browse files Browse the repository at this point in the history
Skip nil params to Merge1D
  • Loading branch information
tpc9000 authored Sep 15, 2022
2 parents fb6692f + 8591d40 commit ea39938
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Array/Merge1D.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ local function Merge1D<T>(...: {T}): {T}

for SubArrayIndex = 2, select("#", ...) do
local SubArray = select(SubArrayIndex, ...)

if (not SubArray) then
continue
end

local Size = #SubArray
table.move(SubArray, 1, Size, Index, Result)
Index += Size
Expand Down
6 changes: 6 additions & 0 deletions src/Map/Merge1D.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ local function Merge1D(...)
local Result = {}

for Index = 1, select("#", ...) do
local Table = select(Index, ...)

if (not Table) then
continue
end

for Key, Value in select(Index, ...) do
Result[Key] = Value
end
Expand Down

0 comments on commit ea39938

Please sign in to comment.