Skip to content

Conversation

@BurdetteLamar
Copy link
Member

No description provided.

Comment on lines 1434 to 1436
* each(sep = $/, chomp: false) {|line| ... } -> self
* each(limit, chomp: false) {|line| ... } -> self
* each(sep, limit, chomp: false) {|line| ... } -> self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep using each_line?
each_line is preferred over each.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree entirely

Can we switch the alias relationship between #each and #each_line? If so, I can do that here (along with changing the call-seq and examples); that would change this PR to not-[DOC].

Would that be okay?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend the following change?

diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index f81dd60..d424c59 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -2032,8 +2032,8 @@ Init_stringio(void)
     rb_define_method(StringIO, "sync=", strio_set_sync, 1);
     rb_define_method(StringIO, "tell", strio_tell, 0);
 
-    rb_define_method(StringIO, "each", strio_each, -1);
     rb_define_method(StringIO, "each_line", strio_each, -1);
+    rb_define_alias(StringIO, "each", "each_line");
     rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
     rb_define_method(StringIO, "each_char", strio_each_char, 0);
     rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);

We don't need it because IO doesn't do it: https://github.com/ruby/ruby/blob/fcf8b10b3c674eecf16c14fa6ee7f4211fa3b673/io.c#L15792-L15793

Can we add alias information by RDoc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDoc adds alias info automatically.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep using each_line? each_line is preferred over each.

Done.

*
* Leaves stream position as end-of-stream.
*
* **No Arguments**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using ### Subsection (####?) instead of **Subsection**?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc guide says not to. I think a reason is that in some renderings, the heading can show up in the left-pane TOC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know it...

Comment on lines 2097 to 2106
* Text = <<EOT
* First line
* Second line
*
* Fourth line
* Fifth line
* EOT
*
* Russian = 'тест'
* Data = "\u9990\u9991\u9992\u9993\u9994"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use UPPER_CASE for constant names such as TEXT, RUSSIAN and DATA?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@BurdetteLamar
Copy link
Member Author

@kou, I also had forgotten keyword arg chomp; now added.

@kou kou merged commit eca2588 into ruby:master Oct 27, 2025
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants