Skip to content

Commit

Permalink
Fix StringIO#write
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Sep 20, 2013
1 parent 2f175bc commit ddd0778
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stdlib/stringio.rb
Expand Up @@ -100,12 +100,14 @@ def write(string)
string = String(string)

if @string.length == @position
@string += string
@string += string
@position += string.length
else
before = @string[0 .. @position - 1]
after = @string[@position + string.length .. -1]

@string = before + string + after
@string = before + string + after
@position += string.length
end
end

Expand Down

0 comments on commit ddd0778

Please sign in to comment.