[ruby-core:76991] [Ruby trunk Feature#12347] [PATCH] Make CSV::Row#each etc. return Enumerator when no block given
From:
kazuki@...
Date:
2016-08-21 05:13:16 UTC
List:
ruby-core #76991
Issue #12347 has been updated by Kazuki Tsujimoto.
I will commit it in a month.
Let me know if you have any concerns.
----------------------------------------
Feature #12347: [PATCH] Make CSV::Row#each etc. return Enumerator when no block given
https://bugs.ruby-lang.org/issues/12347#change-60214
* Author: Kazuki Tsujimoto
* Status: Assigned
* Priority: Normal
* Assignee: James Gray
----------------------------------------
I propose to make following methods return Enumerator when no block given.
* CSV::Row#each
* CSV::Row#delete_if
* CSV::Table#each
* CSV::Table#delete_if
I think that the behavior without block is undefined (and several methods raise error in such a case as follows),
so it will not break compatibility.
~~~
$ ruby -rcsv -e 'CSV::Table.new([CSV::Row.new(%w{A}, [1])]).by_col.each'
/usr/local/ruby-2.3/lib/ruby/2.3.0/csv.rb:850:in `block in each': undefined method `[]' for nil:NilClass (NoMethodError)
from /usr/local/ruby-2.3/lib/ruby/2.3.0/csv.rb:850:in `each'
from /usr/local/ruby-2.3/lib/ruby/2.3.0/csv.rb:850:in `each'
from -e:1:in `<main>'
~~~
---Files--------------------------------
0001-lib-csv.rb-CSV-Row-Table-each-delete_if-Returns-an-e.patch (5.78 KB)
--
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>