From: Loqi Tamaroon Date: 2009-04-18T00:27:03+09:00 Subject: [ruby-core:23236] [Bug #1387] first(0) and last(0) behavior Bug #1387: first(0) and last(0) behavior http://redmine.ruby-lang.org/issues/show/1387 Author: Loqi Tamaroon Status: Open, Priority: Normal ruby -v: 1.8.6 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? ---------------------------------------- http://redmine.ruby-lang.org