[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01898] Re: File operations

From: Dave Thomas <Dave@...>
Date: 2000-03-16 16:33:26 UTC
List: ruby-talk #1898
"David Douthitt" <DDouthitt@cuna.com> writes:

> What is the difference between File.open (open method of File class)
> and internal function open?

For regular files, there is none. However, the 'open' function also
allows you to open pipes to subprocesses (by starting the name with a
pipe character).

> What is the difference between the IO methods each and each_line?

They are synonyms.

> And how does
> File.open(path).each_line { |line|
>    ...
>    }
> 
> differ from
> 
> File.open(path) { |f|
>    f.readlines.each { |line|
>       ....
>       }
>    }
> 
> I know at least that the first reads one line at a time from the file,
> and the second reads the file into an array and iterates over the
> array..... at least I think so.

That's the big difference I can think of.


Dave

In This Thread

Prev Next