Project

General

Profile

Actions

Bug #13925

closed

string.split(pattern, 1) should return [self.dup], but it returns [self]

Added by tompng (tomoya ishida) about 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
[ruby-core:82899]

Description

msg = 'abababababa'
msg.split('b', 4).map(&:upcase!) # won't overwrite msg
puts msg # abababababa (expected)
msg.split('b', 1).map(&:upcase!) # this overwrites msg
puts msg # ABABABABABA (abababababa is expected)

I wrote a patch for this.


Files

split_limit_1.patch (352 Bytes) split_limit_1.patch tompng (tomoya ishida), 09/20/2017 04:31 PM
partition_rpartition.patch (842 Bytes) partition_rpartition.patch hanachin (Seiei Miyagi), 09/20/2017 11:44 PM
Actions

Also available in: Atom PDF