Project

General

Profile

Actions

Bug #20957

open

RangeError on Array#values_at with negative ranges

Added by kyanagi (Kouhei Yanagita) 3 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-12-13T10:19:31Z master 3cb79d4082) +PRISM [arm64-darwin22]
[ruby-core:120257]

Description

[0, 1, 2, 3].values_at(10)       #=> [nil]
[0, 1, 2, 3].values_at(10..10)   #=> [nil]
[0, 1, 2, 3].values_at(-10)      #=> [nil]
[0, 1, 2, 3].values_at(-10..-10) #=> 'Array#values_at': -10..-10 out of range (RangeError)

Is this the intended behavior?

I am aware that this behavior was recently added to the documentation, but I would like to confirm whether it is the intended behavior.

No data to display

Actions

Also available in: Atom PDF

Like0