[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Learn to Program, by Chris Pine

Ball, Donald A Jr (Library)

6/13/2007 9:08:00 PM

> -----Original Message-----
> From: list-bounce@example.com
> [mailto:list-bounce@example.com] On Behalf Of Tm Bo
> Sent: Wednesday, June 13, 2007 4:04 PM
> To: ruby-talk ML
> Subject: Re: Learn to Program, by Chris Pine
>
> Hello all. Thanks to all the posters who came before me!
> You've been tremendous help. I have a quick question on
> Chapter 11 - Reading and Writing, Section 11.3:
>
> <quote>
> file_name = 'TestFile.txt'
> test_string = 'Nothing!'
>
> File.open file_name, 'w' do |f|
> f.write test_string
> end
>
> read_string = File.read file_name
> puts(read_string == test_string)
> </quote>
>
> I poked around the web, but I can't find out what the 'w' is
> for. Can anyone shed any light? Muchas gracias in advance.

http://dev.rubycentral.com/ref/ref_c_file...

the 'w' option opens the file for writing.

- donald

2 Answers

Tm Bo

6/13/2007 9:16:00 PM

0

Thanks, donald. I don't know why I missed that before.

--
Posted via http://www.ruby-....

John Joyce

6/14/2007 2:24:00 PM

0


On Jun 13, 2007, at 4:16 PM, Tm Bo wrote:

> Thanks, donald. I don't know why I missed that before.
>
> --
> Posted via http://www.ruby-....
>
You will do well to make notes on File and read/write modes!
The basic implementation of this kind of thing is almost the same in
many lanugages, Ruby's is no exception, the style of this comes
straight from C .
You will see it in PHP too, and a host of other languages.. (all C's
children and relatives.)
Some books fail to document this stuff well for beginners. they
either don't want to go there yet, or they forget about it since they
assume you know it from other languages.
Mr. Pine just isn't going there in his book. He's focusing on other
subjects