Created
July 2, 2013 13:33
-
-
Save gsamokovarov/5909330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you truncate a StrinIO and don't rewind it, the next write will have | |
# leading zeroes. | |
require 'stringio' | |
s = StringIO.new | |
s.write 'foo' | |
p s.string # => "foo" | |
s.truncate 0 | |
# s.rewind | |
s.write 'bar' | |
p s.string # => "\u0000\u0000\u0000bar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment