? The first example seems to be favoured in "Well Grounded Rubyist" but I discovered I could call each directly on the File.open object as it's enumerable. Any advantages of one over the other?
On Tue, May 6, 2014 at 9:23 AM, gvim <gvimrc@gmail.com> wrote:
What's the difference between:
open('file.txt') {|fh| fh.each {|l| puts l}}
... and:
open('file.txt').each {|l| puts l}
? The first example seems to be favoured in "Well Grounded Rubyist" but I
discovered I could call each directly on the File.open object as it's
enumerable. Any advantages of one over the other?
On Tue, May 6, 2014 at 6:23 PM, gvim <gvimrc@gmail.com> wrote:
What's the difference between:
open('file.txt') {|fh| fh.each {|l| puts l}}
... and:
open('file.txt').each {|l| puts l}
? The first example seems to be favoured in "Well Grounded Rubyist" but I
discovered I could call each directly on the File.open object as it's
enumerable. Any advantages of one over the other?