Each vs. each_line

What is the difference between “each” and “each_line” in Ruby? How do we
decide which one to use?

Thanks.

SW Engineer wrote in post #1168475:

What is the difference between “each” and “each_line” in Ruby? How do we
decide which one to use?

Thanks.

As per the doco - Class: IO (Ruby 2.2.0)

IO#each and IO#each_line works exactly same way. Alias of each other, I
think.

SW Engineer wrote in post #1168475:

What is the difference between “each” and “each_line” in Ruby? How do we
decide which one to use?

Historically #each was there first. For some Enumerable classes the
name was ambiguous (e.g. class String: does it mean “each char” or “each
line”?). So #each_line was added where it makes sense (String, IO).
And in case of String #each was removed (there is also :each_byte,
:each_char, :each_codepoint in String). For IO and ARGF #each and
#each_line are synonyms (I guess #each is the alias and #each_line has
the implementation).