From: naruse@... Date: 2017-03-12T08:09:49+00:00 Subject: [ruby-core:80052] [Ruby trunk Bug#13202] Enumerable#slice_before does not take both argument and block at the same time, as it ought to. Issue #13202 has been updated by Yui NARUSE. 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. ---------------------------------------- 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#change-63479 * Author: Shyouhei Urabe * Status: Closed * 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: DONE ---------------------------------------- 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
' from tmp.rb:2:in `open' from tmp.rb:2:in `
' ``` -- https://bugs.ruby-lang.org/ Unsubscribe: