Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I suspect this is because a table may be used for an object (or some other abstract data type) which has a different data type. Adding another metatable hook for __empty might be another solution, though. (I agree it's a bit annoying.)

> Ok so all is good. But now what happens when the table contains a nil?

One of the invariants for the way Lua tables are implemented is that they won't contain nil as a value, IIRC. Using a multifaceted table type for both arrays and dicts is a mixed blessing. It is really convenient much of the time, but it does lead to some quirks.

NB: The i in "ipairs" means "integer (keyed) pairs".



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: