From: "nobu (Nobuyoshi Nakada)" Date: 2022-03-31T06:46:55+00:00 Subject: [ruby-core:108132] [Ruby master Bug#18670] MatchData#[start, length] pads nil values when negative start is given Issue #18670 has been updated by nobu (Nobuyoshi Nakada). https://github.com/ruby/ruby/pull/5740 ---------------------------------------- Bug #18670: MatchData#[start, length] pads nil values when negative start is given https://bugs.ruby-lang.org/issues/18670#change-97107 * Author: bjfish (Brandon Fish) * Status: Open * Priority: Normal * ruby -v: 3.0.3 * Backport: 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED ---------------------------------------- Example ``` ruby 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: ``` ruby irb(main):002:0> "hello"[-1, 10] => "o" irb(main):003:0> [1,2,3][-1,10] => [3] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: