Skip to content
Permalink
Browse files
Support to call without block to String#each_char
  • Loading branch information
ksss committed Jul 26, 2016
1 parent 32ad74f commit bef63a4f917903da0d5fdb7a01916313a2a26e7e
Showing 1 changed file with 9 additions and 1 deletion.
@@ -362,7 +362,15 @@ def chars(&block)
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

0 comments on commit bef63a4

Please sign in to comment.