Actions
Bug #13202
closedEnumerable#slice_before does not take both argument and block at the same time, as it ought to.
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-02-02 trunk 57498) [x86_64-darwin15]
Backport:
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>'
Updated by naruse (Yui NARUSE) almost 8 years ago
- Related to Feature #10958: remove "initial_state" argument of Enumerable#{slice_before,chunk} added
Updated by akr (Akira Tanaka) almost 8 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) almost 8 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) almost 8 years ago
- Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE
Updated by usa (Usaku NAKAMURA) over 7 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) over 7 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.
Actions
Like0
Like0Like0Like0Like0Like0Like0