3 ms·
Lua tables make no distinction between a table value being nil and the corresponding key not existing in the table necessitating hacks like: http://lua-users.or
by lenkite 4y ago
Lua tables make no distinction between a table value being nil and the corresponding key not existing in the table necessitating hacks like: http://lua-users.org/wiki/StoringNilsInTables http://lua-users.org/wiki/StoringNilsInTables
- edflsafoiewq 4y agoYeah, that's the point of nil. If you're trying to store it in a table, you're just fighting the language. Is there a good motivation for doing that?
- samatman 4y agoI've done this on two rare occasions: round-tripping 'null' in JSON and 'NULL' in database queries. My solution, which was perhaps overly cute, was a table canonically named No, which is callable such that No(nil), No(false), and No(No) all return true. So I could say if No(value) then When I needed to do conditional logic which excludes those reified null values, which isn't often.