Commit 3757b16d authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3184 from ksss/each_char

Support to call without block to String#each_char
parents 32ad74f4 bef63a4f
...@@ -362,7 +362,15 @@ class String ...@@ -362,7 +362,15 @@ class String
self.split('') self.split('')
end end
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) def codepoints(&block)
len = self.size len = self.size
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment