From: nagachika00@... Date: 2017-03-27T14:49:46+00:00 Subject: [ruby-core:80385] [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 nagachika (Tomoyuki Chikanaga). 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. ---------------------------------------- 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-63869 * Author: shyouhei (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: DONTNEED, 2.3: DONE, 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: