summaryrefslogtreecommitdiffhomepage
path: root/mrblib/enum.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-08-22 21:19:34 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-08-22 21:19:34 +0900
commitfd2f2f28debdbce8c08bd91305ecf8073817dc47 (patch)
tree9c5318614b0971f3be01dcc361b351434c2d5213 /mrblib/enum.rb
parent71f2975a5ba93197fac6a08f21d84bc87e31c6ae (diff)
parent85f0dd7da0fe41310883d9a65156c429135590f5 (diff)
downloadmruby-fd2f2f28debdbce8c08bd91305ecf8073817dc47.tar.gz
mruby-fd2f2f28debdbce8c08bd91305ecf8073817dc47.zip
Merge pull request #2922 from gkta/refactor-mrubygem-code
Refactor mrubygem code (range.rb, numeric.rb, string.rb, array.rb, enum.rb)
Diffstat (limited to 'mrblib/enum.rb')
-rw-r--r--mrblib/enum.rb32
1 files changed, 6 insertions, 26 deletions
diff --git a/mrblib/enum.rb b/mrblib/enum.rb
index e979fe90e..f0c9a4884 100644
--- a/mrblib/enum.rb
+++ b/mrblib/enum.rb
@@ -24,17 +24,9 @@ module Enumerable
# ISO 15.3.2.2.1
def all?(&block)
if block
- self.each{|*val|
- unless block.call(*val)
- return false
- end
- }
+ self.each{|*val| return false unless block.call(*val)}
else
- self.each{|*val|
- unless val.__svalue
- return false
- end
- }
+ self.each{|*val| return false unless val.__svalue}
end
true
end
@@ -49,17 +41,9 @@ module Enumerable
# ISO 15.3.2.2.2
def any?(&block)
if block
- self.each{|*val|
- if block.call(*val)
- return true
- end
- }
+ self.each{|*val| return true if block.call(*val)}
else
- self.each{|*val|
- if val.__svalue
- return true
- end
- }
+ self.each{|*val| return true if val.__svalue}
end
false
end
@@ -75,9 +59,7 @@ module Enumerable
return to_enum :collect unless block
ary = []
- self.each{|*val|
- ary.push(block.call(*val))
- }
+ self.each{|*val| ary.push(block.call(*val))}
ary
end
@@ -183,9 +165,7 @@ module Enumerable
# ISO 15.3.2.2.10
def include?(obj)
self.each{|*val|
- if val.__svalue == obj
- return true
- end
+ return true if val.__svalue == obj
}
false
end