diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-22 06:50:32 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-22 06:50:32 +0000 |
commit | f1b7003f35cae684cceeab710a5769458dfe7310 (patch) | |
tree | 3e9967a80821a0c38f456b1b6d803bc2a172a97e /io.c | |
parent | 2a46ba9423f44d2d673525eaa7ea48d12679e279 (diff) | |
download | ruby-f1b7003f35cae684cceeab710a5769458dfe7310.tar.gz |
Allow IO#reopen to take a block
* io.c (rb_io_reopen): take a block and ensure the IO closed
[Feature #2631]
* test/ruby/test_io.rb: add a test
* NEWS: add an entry for this change
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -7058,6 +7058,10 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file) } } + if (rb_block_given_p()) { + return rb_ensure(rb_yield, file, io_close, file); + } + return file; } |