3 ms·
If you intended to calculate an index and you accidentally get len(arr), you get a runtime error. But if you accidentally get -1 you silently get the last eleme
by edflsafoiewq 4y ago
If you intended to calculate an index and you accidentally get len(arr), you get a runtime error. But if you accidentally get -1 you silently get the last element instead. Similar to the argument about signed/unsigned indices in low level languages.
- ilyt 4y agoIf you calculated wrong you can land on positive-but-existing value just fine... > Similar to the argument about signed/unsigned indices in low level languages. Think that one has to do more with convenience where most of stuff uses int by default