Skip to content
Permalink
Browse files
Fixed off-by-one error in String#[]= with Ranges
  • Loading branch information
matz committed Nov 16, 2016
1 parent 1f554ff commit 1685eff2a5e672173d67916a1c96648df92b7271
Showing 1 changed file with 2 additions and 5 deletions.
@@ -173,11 +173,8 @@ def []=(*args)
head = pos.begin
tail = pos.end
tail += self.length if tail < 0
if pos.exclude_end?
tail -= 1
end
if tail < 0 || tail > self.length
raise IndexError, "index #{args[0]} out of string"
unless pos.exclude_end?
tail += 1
end
return self[head, tail-head]=value
else

0 comments on commit 1685eff

Please sign in to comment.