mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Support to call without block to String#each_char
This commit is contained in:
@@ -362,7 +362,15 @@ class String
|
||||
self.split('')
|
||||
end
|
||||
end
|
||||
alias each_char chars
|
||||
|
||||
def each_char(&block)
|
||||
return to_enum :each_char unless block
|
||||
|
||||
split('').map do |i|
|
||||
block.call(i)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def codepoints(&block)
|
||||
len = self.size
|
||||
|
||||
Reference in New Issue
Block a user