[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: possible bug
- From: Mason Mackaman <masondeanm@...>
- Date: Sat, 30 Mar 2013 12:17:24 -0400 (EDT)
Hello everyone, I'm pretty new to programming and even newer to Lua, so
please humor me. I feel I've found a bug but it's most likely just me
being a noob.
function f(set)
local newset,cloneset={},set
for x=1,#cloneset do
newset[x]=cloneset[#cloneset]
table.remove(cloneset)
end
return newset
end
function g(set)
set=f(set)
end
a={1,2,3,4,5,6,7,8,9}
g(a)
print(#a)
This is the simplest form I can put the bug in. I feel like it should
output 9 but instead it outputs 0. If someone could tell my why this is
happening I would be much obliged.
info:
- #f(a)=9
- every time table.remove(cloneset) is executed it also executes the
equivalent of table.remove(a)