Project

General

Profile

Actions

Feature #2631

open

Allow IO#reopen to take a block

Added by djberg96 (Daniel Berger) almost 15 years ago. Updated over 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:27701]

Description

=begin
Please allow IO#reopen to accept a block. This would allow users to temporarily redirect output without having to manually reset the file descriptor. For example:

require 'mkmf'

stdout redirected within block only

$stdout.reopen('/dev/null') do
if have_header('foo.h')
# Do stuff
end
end

stdout now back to its former setting

I believe this is both convenient and intuitive when one considers the IO.open also takes a block.

Regards,

Dan
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0