Hacker News new | ask | show | jobs
by akasakahakada 1025 days ago
When you slice a list, you get a list. When you see there is nothing inside the returning list, you know that means end of list, contains zero element. Slicing and indexing return object at different level.
1 comments

Slicing a list, when the first index is invalid for that list, could easily throw an exception instead.
This should signal an explicit error, which invalid index is indeed. If user believes for some reason the invalid indexing is ok, then it could be caught and handled. No ambiguity.