From: "yhara (Yutaka HARA)" Date: 2012-11-27T12:18:03+09:00 Subject: [ruby-core:50191] [ruby-trunk - Bug #7440] IO#lines etc. should return Array Issue #7440 has been updated by yhara (Yutaka HARA). Eregon (Benoit Daloze) wrote: > Strongly agreed. It could also increase a lot the memory usage (while on String we anyway already have the whole String in memory so it is less of a concern). > > File.open('/usr/share/dict/words').lines.each_with_object(Hash.new(0)) { |word, count| count[word[0].downcase] += 1 } In that case you can use IO#each_line, which still returns Enumerator. File.open('/usr/share/dict/words').each_line.with_object(Hash.new(0)) { |word, count| count[word[0].downcase] += 1 } But in other words, we need to replace uses of IO#lines to IO#each_line, or our existing Ruby program may have performance problem with 2.0.0... # Ticket #6670 is reopened. Please continue discussion there http://bugs.ruby-lang.org/issues/6670 ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440#change-34002 Author: yhara (Yutaka HARA) Status: Open Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more. -- http://bugs.ruby-lang.org/