Issue #13202 has been reported by Shyouhei Urabe.

----------------------------------------
Bug #13202: Enumerable#slice_before does not take both argument and block at the same time, as it ought to.
https://bugs.ruby-lang.org/issues/13202

* Author: Shyouhei Urabe
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0dev (2017-02-02 trunk 57498) [x86_64-darwin15]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Both RDoc and Rurema have descriptions of Enumerable#slice_before with this example:

```ruby
# 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>'
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>