I'm sorry for imparting this cursed knowledge on you today. You already knew lua arrays start at 1 right? Well...
=> More informations about this toot | More toots from mdiluz@mastodon.gamedev.place
Tbf this is only weird when you're thinking of lua as having arrays at all, which it doesn't. It's basically the same in python and doesn't look so weird.
a = {} for i in range(-5, 5): a[i] = i for i in range(-5, 5): print(a[i])
=> More informations about this toot | More toots from mdiluz@mastodon.gamedev.place
@mdiluz Thanks, I hate this.
=> More informations about this toot | More toots from RobLoach@fosstodon.org
@mdiluz @mdiluz To go way into it :D that's the abstraction Lua provides but the -5 to 0 would come out of the dictionary part of the table using their hash value as a key, whereas 1-5 come out the array part of the table. So if you're using the tables as arrays it's treated a little differently underneath to be faster.
=> More informations about this toot | More toots from danschuller@mastodon.gamedev.place
@danschuller Yeah exactly, it's fascinating the path they went there - "Hey you know we could just use a table as an array and special case internally when it looks like you're using it like an array"
Quite elegant imho, in a cursed way.
=> More informations about this toot | More toots from mdiluz@mastodon.gamedev.place This content has been proxied by September (3851b).Proxy Information
text/gemini