Project

General

Profile

Actions

Feature #8929

closed

CSV.foreach(filename) without block returns failing Enumerator

Added by martinjos (Martin Sidaway) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:57283]

Description

CSV.foreach(filename) {|entry| p entry } => works
CSV.foreach(filename).to_a => fails

It gives the following error:

IOError: closed stream
from /home/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/csv.rb:1776:in gets' from /home/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/csv.rb:1776:in block in shift'
from /home/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/csv.rb:1774:in loop' from /home/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/csv.rb:1774:in shift'
from /home/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/csv.rb:1716:in each' from (irb):7:in each'
from (irb):7:in `to_a'
(...)

Actions

Also available in: Atom PDF