File.open, open and IO.foreach in Ruby, what is the difference?

Viewed 30027

All of the following API do the same thing: open a file and call a block for each line. Is there any preference we should use one than another?

File.open("file").each_line {|line| puts line}
open("file").each_line {|line| puts line}   
IO.foreach("file") {|line | puts line}
1 Answers
Related