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>'
Actions
Like0
Like0Like0Like0Like0Like0Like0