【发布时间】:2012-10-30 01:57:23
【问题描述】:
假设你关闭了一个 ruby File 对象
f = File.open('testfile')
f.close
f.each_byte { ... } #=> IOError: closed stream
我知道您可以通过f = File.open(f) 重新打开流,但是有没有办法通过对象上的IO 方法重新打开流?
例如
f.close
f.open_again
f.each_byte { ... }
【问题讨论】:
-
我看到了
f.reopen,但它看起来不像我想要的。