Project

General

Profile

Actions

Feature #4414

closed

Addition to String.split

Added by lorensr (Loren Sands-Ramshaw) about 14 years ago. Updated about 13 years ago.

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

Description

=begin
I'm wondering whether the following feature is acceptable before I work on a patch:

When String.split is given one or more integer arguments, the string is divided at those indices.

str = '1.9ruby30932'
version, language, revision = str.split(3, 7)

Thanks,
Loren
=end

Actions #1

Updated by naruse (Yui NARUSE) about 14 years ago

=begin
Your proposal seems valid, because current String#split only accept arguments whose first argument has to_str method.

The problem is the use case can be solbed by String#unpack (or lib/scanf.rb) like following.

version, language, revision = str.unpack('a3a4a*')
=end

Updated by shyouhei (Shyouhei Urabe) about 13 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected

Please use unpack instead.

Actions

Also available in: Atom PDF

Like0
Like0Like0