Merge pull request #85 from ksss/read

Support outbuf argument for IO#read
This commit is contained in:
Tomoyuki Sahara
2017-06-12 16:17:53 +09:00
committed by GitHub
+7 -2
View File
@@ -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)