1 parent f8b31a0 commit 6eb02a8Copy full SHA for 6eb02a8
1 file changed
mrblib/string.rb
@@ -11,11 +11,12 @@ class String
11
# ISO 15.2.10.5.15
12
def each_line(&block)
13
offset = 0
14
- while pos = self.index("\n", offset)
15
- block.call(self[offset, pos + 1 - offset])
+ this = dup
+ while pos = this.index("\n", offset)
16
+ block.call(this[offset, pos + 1 - offset])
17
offset = pos + 1
18
end
- block.call(self[offset, self.size - offset]) if self.size > offset
19
+ block.call(this[offset, this.size - offset]) if this.size > offset
20
self
21
22
0 commit comments