Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIO#openにブロックを渡した際の戻り値が違う? #157

Closed
murachue opened this issue Jan 7, 2015 · 1 comment
Closed

Comments

@murachue
Copy link

murachue commented Jan 7, 2015

--- open(string = '', mode = 'r+') {|io| ... } -> StringIO

--- open(string = '', mode = 'r+') {|io| ... } -> StringIO

動作を見る限りでは、StringIO#openにブロックを渡した場合は、StringIO(のインスタンス)ではなくブロックを評価した結果が返ってきているように思います。

% ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x64-mswin64_100]

% irb
irb(main):001:0> require "stringio"
=> true
irb(main):002:0> StringIO.open { |f| f.write "hello" }
=> 5
irb(main):003:0> StringIO.open { |f| f.write "hello"; 123 }
=> 123
irb(main):004:0> StringIO.open { |f| f.write "hello"; f }
=> #<StringIO:0x000000020db428>
irb(main):005:0>
@sho-h
Copy link
Member

sho-h commented Jan 8, 2015

ありがとうございます。1.8.7まで遡りましたが以下と同じでした。ご指摘の通りでしたので修正しました。

@sho-h sho-h closed this as completed Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants