[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Behaviour of table.remove()
- From: Марк Гуревич <mark_gurevich@...>
- Date: Thu, 29 Oct 2009 15:31:22 +0300
Hello, everyone!
Could somebody explain me the behaviour of table.remove() in the following code:
function f(t)
print(t[1], t[2])
table.remove(t,1)
print(t[1], t[2])
table.remove(t,1)
print(t[1], t[2])
end
f{1,nil,3}
f{1,nil,3,4}
The output of f{1,nil,3} is
1 nil
nil 3
nil 3
and the output of f{1,nil,3,4} is
1 nil
nil 3
3 4
Why does the second call of table.remove() leave nil in t for f{1,nil,3} and remove nil from t for f{1,nil,3,4} ?