3 ms·
I think it just comes down to where you want your index-out-of-range errors to occur. Pretty much any language I can think of inits primitives with all bits se
by waiseristy 6y ago
I think it just comes down to where you want your index-out-of-range errors to occur.
Pretty much any language I can think of inits primitives with all bits set to 0. So either, you accidentally forget to set your index vars to 1 and out-of-range it there, or accidentally forget to take away 1 when accessing the end of the array. Pick your poison
- foerbert 6y agoI don't think it simplifies quite that far. There are languages that are capable of catching such errors ahead of time. Now that I think about it, there are even more that catch the initialization error - or at least do so more automatically than the end point error.
- IlliOnato 6y agoPerl initializes its scalars to "undef", not 0. If you try to use undef as an array index, it will convert it to 0 but issue a warning. I'd prefer it to be an error instead.