Project

General

Profile

Actions

Feature #15093

open

Retrive Array elements with infinite ranges specified by Float::INFINITY

Added by v0dro (Sameer Deshmukh) about 6 years ago. Updated about 6 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:88905]

Description

Currently in Ruby head (2.6) the following gives an error:

2.6-head :001 > a = [1,2,3,4]
# => [1, 2, 3, 4] 
2.6-head :002 > a[0..Float::INFINITY]
#Traceback (most recent call last):
#        2: from /home/sameer/.rvm/rubies/ruby-2.6-head/bin/irb:11:in `<main>'
#        1: from (irb):2
#RangeError (float Inf out of range of integer)

I think Array should support infinite ranges created by Float::INFINITY as well
since 0..nil and 0..Float::INFINITY are both supposed to create 'infinite' ranges
and having different behavior for each of them is inconsistent.

Actions

Also available in: Atom PDF

Like0
Like0Like0