Actions
Bug #18957
closedStringIO#printf doesn't ignore initial String value
Description
I've noticed that StringIO#printf
diverges from IO#printf
in the following way:
IO:
File.write("printf.txt", "1234567890")
f = File.open("printf.txt", "w+")
f.printf("%s", "abc")
f.rewind
f.gets
# => "abc"
StringIO:
io = StringIO.new("1234567890")
io.printf("%s", "abc")
io.rewind
io.gets
=> "abc4567890"
So File
opened in a w
mode "truncates" existing file content but StirngIO
(by default) doesn't.
I would expect StringIO
behaves in the same way.
Actions
Like0
Like0Like0Like0