Commit 2b4ed40f authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3185 from kou/string-reduce-needless-array

Reduce needless Array generation in some String methods
parents 3757b16d 6bb0775d
......@@ -354,7 +354,7 @@ class String
def chars(&block)
if block_given?
self.split('').map do |i|
self.split('').each do |i|
block.call(i)
end
self
......@@ -366,7 +366,7 @@ class String
def each_char(&block)
return to_enum :each_char unless block
split('').map do |i|
split('').each do |i|
block.call(i)
end
self
......@@ -376,7 +376,7 @@ class String
len = self.size
if block_given?
self.split('').map do|x|
self.split('').each do|x|
block.call(x.ord)
end
self
......
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