mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #85 from ksss/read
Support outbuf argument for IO#read
This commit is contained in:
+7
-2
@@ -183,7 +183,7 @@ class IO
|
||||
nil
|
||||
end
|
||||
|
||||
def read(length = nil)
|
||||
def read(length = nil, outbuf = "")
|
||||
unless length.nil?
|
||||
unless length.is_a? Fixnum
|
||||
raise TypeError.new "can't convert #{length.class} into Integer"
|
||||
@@ -215,7 +215,12 @@ class IO
|
||||
end
|
||||
end
|
||||
|
||||
array && array.join
|
||||
if array.nil?
|
||||
outbuf.replace("")
|
||||
nil
|
||||
else
|
||||
outbuf.replace(array.join)
|
||||
end
|
||||
end
|
||||
|
||||
def readline(arg = $/, limit = nil)
|
||||
|
||||
Reference in New Issue
Block a user