Support to call without block to String#each_char

This commit is contained in:
ksss
2016-07-26 18:40:16 +09:00
parent 32ad74f4d1
commit bef63a4f91
+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