3 ms·
In my opinion Lua's equivalent tables or more of a Swiss army knife. It's been a while since I've used them but afair they combine hash/dict, array and objects
by sottol 3y ago
In my opinion Lua's equivalent tables or more of a Swiss army knife.
It's been a while since I've used them but afair they combine hash/dict, array and objects in one data structure.
They're hashes as usual. With a special constructor or int keys they turn into arrays, last I looked the Lua interpreter even optimizes contiguous ranges of keys as arrays. And by adding metatables and metamethods they also emulate JS-style objects.
- omoikane 3y agoMy feeling with Lua is that it's lacking arrays due to minimalism, as in "we don't need arrays because tables will do". Probably the same reason why there is no "continue" in a for-loop. In comparison, Ruby has arrays and hashes, and gives me the feeling "yes these do exactly what you expected, but wait there is more!" In that sense it does feel more like a Swiss army knife.
- astrobe_ 3y agoOn the contrary, they acknowledged that hash tables only was pushing it a bit too far, so they implemented arrays sort of "on the side" of tables.