mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
io.rb: reimplement IO#each_char.
It used to be an alias to `IO#each_byte` but those methods should have behave differently.
This commit is contained in:
@@ -330,7 +330,7 @@ class IO
|
||||
def each_byte(&block)
|
||||
return to_enum(:each_byte) unless block
|
||||
|
||||
while char = self.getc
|
||||
while char = self.getbyte
|
||||
block.call(char)
|
||||
end
|
||||
self
|
||||
@@ -339,7 +339,14 @@ class IO
|
||||
# 15.2.20.5.5
|
||||
alias each_line each
|
||||
|
||||
alias each_char each_byte
|
||||
def each_char(&block)
|
||||
return to_enum(:each_byte) unless block
|
||||
|
||||
while char = self.getc
|
||||
block.call(char)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def readlines
|
||||
ary = []
|
||||
|
||||
Reference in New Issue
Block a user