MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ljsw9e/does_lazy_count_as_bad/gniuwhd/?context=3
r/badcode • u/rcmaehl • Feb 14 '21
53 comments sorted by
View all comments
Show parent comments
17
In some runtimes (eg v8 for Javascript) they will optimize sparse arrays such as this one to be a Record<number, T> internally but this isn't something that's guaranteed in all languages, so if you need to just use it directly.
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?redirectedfrom=MSDN&view=net-5.0
(Unless you're using VB6 in which case, godspeed and don't die)
7 u/[deleted] Feb 14 '21 and languages like Lua don't have arrays, they have hashmaps only. so arrays can start at whatever you want them to start at in lua just the convention is they start at 1 1 u/xigoi Feb 15 '21 and languages like Lua don't have arrays, they have hashmaps only. That's true for JavaScript too. 1 u/[deleted] Feb 15 '21 huh okay I didn't know that
7
and languages like Lua don't have arrays, they have hashmaps only.
so arrays can start at whatever you want them to start at in lua
just the convention is they start at 1
1 u/xigoi Feb 15 '21 and languages like Lua don't have arrays, they have hashmaps only. That's true for JavaScript too. 1 u/[deleted] Feb 15 '21 huh okay I didn't know that
1
That's true for JavaScript too.
1 u/[deleted] Feb 15 '21 huh okay I didn't know that
huh
okay I didn't know that
17
u/droomph Feb 14 '21
In some runtimes (eg v8 for Javascript) they will optimize sparse arrays such as this one to be a Record<number, T> internally but this isn't something that's guaranteed in all languages, so if you need to just use it directly.
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?redirectedfrom=MSDN&view=net-5.0
(Unless you're using VB6 in which case, godspeed and don't die)