News for hackers. Stuff that matters.
Re:Optimizing Ruby Path Methods by weaksauce on Sunday April 19, 2026 @08:43PM (#47829109)
looked into it more and the docs say that an index out of bounds will return nil. also says if offset == size and length >= 0 it will return an empty array.

``` If offset == self.size and size >= 0, returns a new empty array.

If size is negative, returns nil. ```

either way if you are doing stuff with arrays and not checking bounds you can throw an `Array(some_array.slice(x, x+100))` and it will always behave.

Re:Optimizing Ruby Path Methods by saghm on Sunday April 19, 2026 @10:05PM (#47829562)
Sure, the docs seem to be accurate, but that only explains "what will this do?", not "why is this what it will do?" It's not what I expect most people would come up with if they designed this API, so I have to wonder why they didn't pick something more intuitive