Project

General

Profile

Bug #13202

Enumerable#slice_before does not take both argument and block at the same time, as it ought to.

Added by shyouhei (Shyouhei Urabe) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-02-02 trunk 57498) [x86_64-darwin15]
[ruby-core:79485]

Description

Both RDoc and Rurema have descriptions of Enumerable#slice_before with this example:

# split mails in mbox (slice before Unix From line after an empty line)
open("mbox") { |f|
  f.slice_before(emp: true) { |line, h|
    prevemp = h[:emp]
    h[:emp] = line == "\n"
    prevemp && line.start_with?("From ")
  }.each { |mail|
    mail.pop if mail.last == "\n"
    pp mail
  }
}

which doesn't work.

zsh % ruby -v tmp.rb
ruby 2.5.0dev (2017-02-02 trunk 57498) [x86_64-darwin15]
tmp.rb:3:in `slice_before': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from tmp.rb:3:in `block in <main>'
        from tmp.rb:2:in `open'
        from tmp.rb:2:in `<main>'

Related issues

Related to Ruby trunk - Feature #10958: remove "initial_state" argument of Enumerable#{slice_before,chunk}Closed03/10/2015Actions

Associated revisions

Revision cd5f5715
Added by akr (Akira Tanaka) over 2 years ago

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe. [Bug #13202]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57584
Added by akr (Akira Tanaka) over 2 years ago

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe. [Bug #13202]

Revision 57584
Added by akr (Akira Tanaka) over 2 years ago

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe. [Bug #13202]

Revision 57584
Added by akr (Akira Tanaka) over 2 years ago

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe. [Bug #13202]

Revision 8a4f4f20
Added by naruse (Yui NARUSE) about 2 years ago

merge revision(s) 57584: [Backport #13202]

    [DOC] Update an obsolete example for slice_before.

    The argument for Enumerable#slice_before is is removed at Ruby 2.3.

    Reported by Shyouhei Urabe.  [Bug #13202]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57905
Added by naruse (Yui NARUSE) about 2 years ago

merge revision(s) 57584: [Backport #13202]

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe.  [Bug #13202]

Revision 783286fe
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57584: [Backport #13202]

    [DOC] Update an obsolete example for slice_before.

    The argument for Enumerable#slice_before is is removed at Ruby 2.3.

    Reported by Shyouhei Urabe.  [Bug #13202]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58155
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57584: [Backport #13202]

[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe.  [Bug #13202]

History

#1

Updated by naruse (Yui NARUSE) over 2 years ago

  • Related to Feature #10958: remove "initial_state" argument of Enumerable#{slice_before,chunk} added
#2

Updated by akr (Akira Tanaka) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57584.


[DOC] Update an obsolete example for slice_before.

The argument for Enumerable#slice_before is is removed at Ruby 2.3.

Reported by Shyouhei Urabe. [Bug #13202]

Updated by naruse (Yui NARUSE) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE

ruby_2_4 r57905 merged revision(s) 57584.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE
#5

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONE

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONE to 2.2: DONTNEED, 2.3: DONE, 2.4: DONE

ruby_2_3 r58155 merged revision(s) 57584.

Also available in: Atom PDF