4 ms·
Associative arrays are also "nicer" with 1 based indexing t={} t[#t+1] --> t[1] DONE! t[#t==0 and 0 or #t+1] Now, in order to fix this (or achieve the s
by nmz 2y ago
Associative arrays are also "nicer" with 1 based indexing
t={}
t[#t+1] --> t[1] DONE!
t[#t==0 and 0 or #t+1]
Now, in order to fix this (or achieve the same behavior as #t+1), the length operator must return -1, which would be ridiculous. its empty, and we have a perfect representation of emptiness in math "0".
This is also true in awk as well, nobody ever whines about awk "arrays" being 0