Ruby 1.8.1 write to file?

Hi!

I have upgraded to ruby 1.8.1 … and suddenly now my file-writing does
not work. I get an error like:

script:line:in `close’: uninitialized stream (IOError)

The code looks like this:

File.open(“e_macs.txt”, “a”) { |f|
f << Time.new.to_s
f << “\n”
}

What happend in writing to files from 1.6 to 1.8? I tried my way through
rubycentral.com … but apparently the API is not updated.

How do I handle file writing (or reading) in Ruby 1.8?

Cheers, Kristian Sørensen.

Can you show us your ruby -v output? I’m on “ruby 1.8.1 (2003-12-25)
[powerpc-darwin]” and it works without a problem.

Chad

···

On Mar 14, 2004, at 8:04 PM, Kristian Sørensen wrote:

Hi!

I have upgraded to ruby 1.8.1 … and suddenly now my file-writing does
not work. I get an error like:

script:line:in `close’: uninitialized stream (IOError)

The code looks like this:

File.open(“e_macs.txt”, “a”) { |f|
f << Time.new.to_s
f << “\n”
}

What happend in writing to files from 1.6 to 1.8? I tried my way
through rubycentral.com … but apparently the API is not updated.

How do I handle file writing (or reading) in Ruby 1.8?

Chad Fowler wrote:

Hi!

I have upgraded to ruby 1.8.1 … and suddenly now my file-writing does
not work. I get an error like:

script:line:in `close’: uninitialized stream (IOError)

The code looks like this:

File.open(“e_macs.txt”, “a”) { |f|
f << Time.new.to_s
f << “\n”
}

What happend in writing to files from 1.6 to 1.8? I tried my way
through rubycentral.com … but apparently the API is not updated.

How do I handle file writing (or reading) in Ruby 1.8?

Can you show us your ruby -v output? I’m on “ruby 1.8.1 (2003-12-25)
[powerpc-darwin]” and it works without a problem.
Just now I figured the problem: error 40! (40 cm away from the screen)
I made a class myselv, which was called “File” … :slight_smile: Then naturally,
the intended, default methods did not exist.

Cheers, KS.

···

On Mar 14, 2004, at 8:04 PM, Kristian Sørensen wrote: