Skip to content

Commit

Permalink
Support to call without block to String#each_char
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Jul 26, 2016
1 parent 32ad74f commit bef63a4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mrbgems/mruby-string-ext/mrblib/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bef63a4

Please sign in to comment.