6 ms·
> "Slicing past the end of array results in a runtime panic. Ignoring out of bound indices is more convenient (and consistent with how other languages handle th
by Queue29 12y ago
> "Slicing past the end of array results in a runtime panic. Ignoring out of bound indices is more convenient (and consistent with how other languages handle this)."
Ignoring logic bugs sounds like a horrible idea
- axk 12y agoIt's not always logic bugs. For example, here's how you would limit your slice to max N elements: arr = arr[:N] ...compared how it has to be done to avoid a panic: if len(arr) > N { arr = arr[:N] } Not a big deal though, just slightly more verbose.