each_line(*args) {|line| ... } -> nil
[permalink][rdoc][edit]each_line(*args) -> Enumerator
-
IO.foreach(self.to_s, *args, &block) と同じです。
require "pathname" IO.write("testfile", "line1\nline2,\nline3\n") Pathname("testfile").each_line # => #<Enumerator: IO:foreach("testfile")>
require "pathname" IO.write("testfile", "line1\nline2,\nline3\n") Pathname("testfile").each_line {|f| p f } # => "line1\n" # => "line2,\n" # => "line3\n"
require "pathname" IO.write("testfile", "line1\nline2,\nline3\n") Pathname("testfile").each_line(4) {|f| p f } # => "line" # => "1\n" # => "line" # => "2,\n" # => "line" # => "3\n"
require "pathname" IO.write("testfile", "line1\nline2,\nline3\n") Pathname("testfile").each_line(",") {|f| p f } # => "line1\nline2," # => "\nline3\n"
[SEE_ALSO] IO.foreach