Issue #6670 has been updated by mame (Yusuke Endoh).

Assignee changed from matz (Yukihiro Matsumoto) to yhara (Yutaka HARA)

Okay, I understand that it may be harmful to change the behavior right now.
Then, let's warn a user to use `each_line' instead in 2.0.0, and change it in future.

Yhara-san, could you create the following type of patch for all methods?


diff --git a/io.c b/io.c
index bacc6fc..26d3970 100644
--- a/io.c
+++ b/io.c
@@ -10795,6 +10795,13 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
     }
 }

+static VALUE
+argf_lines(int argc, VALUE *argv, VALUE argf)
+{
+    rb_warn("ARGF#lines will return an Array in future; you should use `each_line' instead");
+    return argf_each_line(argc, argv, argf);
+}
+
 /*
  *  call-seq:
  *     ARGF.bytes     {|byte| block }  -> ARGF
@@ -11557,7 +11564,7 @@ Init_IO(void)
     rb_define_method(rb_cARGF, "each_line",  argf_each_line, -1);
     rb_define_method(rb_cARGF, "each_byte",  argf_each_byte, 0);
     rb_define_method(rb_cARGF, "each_char",  argf_each_char, 0);
-    rb_define_method(rb_cARGF, "lines", argf_each_line, -1);
+    rb_define_method(rb_cARGF, "lines", argf_lines, -1);
     rb_define_method(rb_cARGF, "bytes", argf_each_byte, 0);
     rb_define_method(rb_cARGF, "chars", argf_each_char, 0);

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Feature #6670: str.chars.last should be possible
https://bugs.ruby-lang.org/issues/6670#change-34003

Author: yhara (Yutaka HARA)
Status: Assigned
Priority: Normal
Assignee: yhara (Yutaka HARA)
Category: core
Target version: 2.0.0


=begin
Since str.chars returns an Enumerator, we need explicit to_a for some operations:

  str.chars.to_a.last
  str.chars.to_a[1,3]

But often I forget that and write:

  str.chars.last
  str.chars[1,3]

Besides that, I feel it is hard to explain why to_a is needed here when I'm writing
artilcles for Ruby beginners. 

Simplest way to achieve this is to make String#chars (also #lines, #bytes and #codepoints)
return an Array. Since arrays have most of the methods defined in Enumerator, this will 
not be a big change. For programs like str.chars.next, you can use each_char instead.
=end



-- 
http://bugs.ruby-lang.org/