Project

General

Profile

Actions

Bug #18670

closed

MatchData#[start, length] pads nil values when negative start is given

Added by bjfish (Brandon Fish) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:108122]

Description

Example

irb(main):001:0> /(.)(.)(\d+)(\d)/.match("THX1138.")[-1, 10]
=> ["8", nil, nil, nil, nil, nil, nil, nil, nil, nil]

I would expect this to be consistent with String or Array for example:

irb(main):002:0> "hello"[-1, 10]
=> "o"
irb(main):003:0> [1,2,3][-1,10]
=> [3]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0