Project

General

Profile

Actions

Feature #8929

closed

CSV.foreach(filename) without block returns failing Enumerator

Added by martinjos (Martin Sidaway) about 11 years ago. Updated about 11 years ago.

Status:
Closed
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

Like0
Like0Like0Like0Like0Like0Like0Like0