diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-10-17 20:50:22 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-10-17 20:50:22 +0900 |
| commit | bc4799361e171cc91c4f944604ce2e950043e09c (patch) | |
| tree | 917513af81f5f20534608ebd57a5135067d8cdf1 | |
| parent | 84db8edadeb71b2aa68b4c180597b7b7e00d0145 (diff) | |
| parent | 14870a290da5d6618923a52afa98122429985bab (diff) | |
| download | mruby-bc4799361e171cc91c4f944604ce2e950043e09c.tar.gz mruby-bc4799361e171cc91c4f944604ce2e950043e09c.zip | |
Merge pull request #4776 from shuujii/make-IO-each-family-without-block-to-return-Enumerator
Make `IO#each` family without block to return `Enumerator`
| -rw-r--r-- | mrbgems/mruby-io/mrblib/io.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mrbgems/mruby-io/mrblib/io.rb b/mrbgems/mruby-io/mrblib/io.rb index 8297cb1b5..5c06dc5d8 100644 --- a/mrbgems/mruby-io/mrblib/io.rb +++ b/mrbgems/mruby-io/mrblib/io.rb @@ -303,6 +303,8 @@ class IO # 15.2.20.5.3 def each(&block) + return to_enum unless block + while line = self.gets block.call(line) end @@ -311,6 +313,8 @@ class IO # 15.2.20.5.4 def each_byte(&block) + return to_enum(:each_byte) unless block + while char = self.getc block.call(char) end |
