Created
July 31, 2012 17:25
-
-
Save tarcieri/3218710 to your computer and use it in GitHub Desktop.
For people with crazysauce ideas about the interactions of Ruby IO objects and #each
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.9.3-p0 :001 > reader, writer = IO.pipe | |
| => [#<IO:fd 5>, #<IO:fd 6>] | |
| 1.9.3-p0 :002 > writer.respond_to? :each | |
| => true | |
| 1.9.3-p0 :003 > reader.respond_to? :each | |
| => true | |
| 1.9.3-p0 :004 > class << reader; undef :each; end | |
| => nil | |
| 1.9.3-p0 :005 > class << writer; undef :each; end | |
| => nil | |
| 1.9.3-p0 :006 > reader.respond_to? :each | |
| => false | |
| 1.9.3-p0 :007 > writer.respond_to? :each | |
| => false | |
| 1.9.3-p0 :008 > writer << "data" | |
| => #<IO:fd 6> | |
| 1.9.3-p0 :009 > reader.read(4) | |
| => "data" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment