Merge pull request #5693 from dearblue/each_byte

Improvements to `String#each_byte`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-04-18 09:58:59 +09:00
committed by GitHub
+2 -3
View File
@@ -150,10 +150,9 @@ class String
# Call the given block for each byte of +self+.
def each_byte(&block)
return to_enum(:each_byte, &block) unless block
bytes = self.bytes
pos = 0
while pos < bytes.size
block.call(bytes[pos])
while pos < bytesize
block.call(getbyte(pos))
pos += 1
end
self