[ruby-core:77182] [Ruby trunk Feature#12347][Closed] [PATCH] Make CSV::Row#each etc. return Enumerator when no block given
From:
kazuki@...
Date:
2016-09-07 07:08:35 UTC
List:
ruby-core #77182
Issue #12347 has been updated by Kazuki Tsujimoto.
Status changed from Assigned to Closed
committed at r56083.
----------------------------------------
Feature #12347: [PATCH] Make CSV::Row#each etc. return Enumerator when no block given
https://bugs.ruby-lang.org/issues/12347#change-60396
* Author: Kazuki Tsujimoto
* Status: Closed
* 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>