Project

General

Profile

Actions

Bug #11975

closed

Range#last is not consistent and possibly does not do what is expected.

Added by ioquatix (Samuel Williams) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:72800]

Description

The following example demonstrates an inconsistency with Range:

This is expected behaviour:

(0..10).last => 10
(0..10).to_a.last => 10

This is unexpected behaviour:

(0...10).last => 10 # (should be 9?)
(0...10).to_a.last => 9

I believe that Range#last should give the last valid value for a range. Discussion?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0