[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: finding out number of records in a table??
- From: "Paul Hudson" <phudson@...>
- Date: Tue, 12 Sep 2006 20:25:48 +0100
>That is, I'm sorry, but I fail to see why one might need a __removeindex
>metamethod.
That's because you didn't try removing an index :)
> require'hash'
> h=newhash()
> h.k1=10
> h.k2=20
> = getmetatable(h).__len(h)
2
> h.k1=nil
> = getmetatable(h).__len(h)
2
Oops. It only has one element after I removed k1
(sorry for the getmetatable stuff, this is 5.0 so no #h - this is
equivalent, though)