summaryrefslogtreecommitdiffhomepage
path: root/mrblib/string.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-05-15 14:59:48 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-05-15 14:59:48 +0900
commit780342eddb880a1c0a457311b005398ce36d0c9f (patch)
tree40f29b6c7777c7d81871fc2e107097165f2a5b83 /mrblib/string.rb
parent138845a5194a8a0b51e3d68a3b27c82b5795616a (diff)
downloadmruby-780342eddb880a1c0a457311b005398ce36d0c9f.tar.gz
mruby-780342eddb880a1c0a457311b005398ce36d0c9f.zip
Add Enumerator support to `String#each_byte`.
`String#each_byte` is not defined in ISO Ruby but it is implemented in the core mruby because it's useful.
Diffstat (limited to 'mrblib/string.rb')
-rw-r--r--mrblib/string.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/mrblib/string.rb b/mrblib/string.rb
index 42d594055..b0fe4033e 100644
--- a/mrblib/string.rb
+++ b/mrblib/string.rb
@@ -167,6 +167,7 @@ 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