Skip to content

Commit 3ead9b1

Browse files
committed
update concat logic - now it's returning a new table instead of changes the previous table
1 parent ff2b5d1 commit 3ead9b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

array.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,17 @@ array = {
169169
raises_error(array, obj, 'concat')
170170
raises_error(array, obj2, 'concat')
171171

172+
local output = {}
173+
174+
for i=1, #obj do
175+
table.insert(output, obj[i])
176+
end
177+
172178
for i=1, #obj2 do
173-
table.insert(obj, obj2[i])
179+
table.insert(output, obj2[i])
174180
end
175181

176-
return obj
182+
return output
177183
end,
178184

179185
uniq = function(obj)

0 commit comments

Comments
 (0)