lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>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)