From: Brian Candler Date: 2010-07-01T03:26:03+09:00 Subject: Re: Reading String Data as a File Robert Klemme wrote: > The non block form obviously returns the Tempfile instance and if you > want it to be returned from the block what stops you from explicitly > returning it? Only that it's a bit verbose: tf = nil Tempfile.open(...) do |io| tf = io ... end puts tf.path http://redmine.ruby-lang.org/issues/show/504 > IMHO the method with block should return whatever the implementor of the > block chooses. That is far more reusable than always returning the > Tempfile. Maybe that's what the accepted patch does - I haven't tested it. It would be consistent with File.open { ... } if it worked that way. Anyway, I think we're talking about minutiae. You say that one should close the file at the earliest opportunity to "save resources", but the only resource we're talking about is one slot in the kernel file descriptor table, and most apps aren't going to be constrained by that. -- Posted via http://www.ruby-forum.com/.