This project is closed and read-only.
Actions
Bug #1387
closedfirst(0) and last(0) behavior
Bug #1387:
first(0) and last(0) behavior
Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
1.8.6
Description
=begin
I'm not sure if there was an explicit decision to have Array#first(0) and last(0) return the entire receiver, but it's messing me up slightly.
"abc".first(3) => "abc"
"abc".first(2) => "ab"
"abc".first(1) => "a"
"abc".first(0) => "abc"
There's similar behavior with last(0).
In my opinion, first(0) and last(0) should return a zero-length collection.
Is there a rationale for their current behavior, or is it a mistake?
=end
Actions