News for hackers. Stuff that matters.
Re:Optimizing Ruby Path Methods by weaksauce on Saturday April 18, 2026 @10:46PM (#47821409)
because it's meant to be a more functional language. if slicing an array out of bounds threw an error it would be java.

[].slice(0, 100).each do |x| puts x end

that shouldn't be an error and it seems to be the principle of least surprise imo.

Re:Optimizing Ruby Path Methods by t-writescode on Sunday April 19, 2026 @09:26AM (#47824165)
Sorry, I mis-spoke earlier, this is what I should have shared:

  [].slice(5, 100)
^-- *THIS* either returns nil or throws an exception.

( I made the other comment like this longer, please use that one for context )