Project

General

Profile

Actions

Feature #4335

closed

String#split for empty string is always empty array

Added by phasis68 (Heesob Park) about 13 years ago. Updated almost 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
[ruby-core:34926]

Description

Here is ruby's behavior:

' '.split('/')
# => [" "]
''.split('/')
# => []
'/'.split('/')
# => []

Here is Python's behavior:

 >>> ' '.split('/')
 [' ']
 >>> ''.split('/')
 ['']
 >>> '/'.split('/')
 ['', '']

Is there any chance to let ''.split('/') return [''] instead of []?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #3575: String#split is inconsistent with empty string and negative limitCloseddrbrain (Eric Hodel)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0