Merge pull request #3184 from ksss/each_char

Support to call without block to String#each_char
This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-07-27 02:32:04 +09:00
committed by GitHub
+9 -1
View File
@@ -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