[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.setn was deprecate, what is new function to replace it?
- From: Dirk Laurie <dpl@...>
- Date: Sun, 1 May 2011 21:44:56 +0200
On Sun, May 01, 2011 at 09:04:38PM +0200, lin_style wrote:
> thanks!
Your subject line was:
table.setn was deprecate, what is new function to replace it?
In Lua 5.2, something like this:
function setn(t,n)
setmetatable(t,{__len=function() return n end})
end
a={1,2,3,nil,5}
print(#a) --> 5
setn(a,3)
print(#a) --> 3
Dirk