mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Refactor Enumerable#any?
This commit is contained in:
+3
-6
@@ -48,23 +48,20 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.2
|
||||
def any?(&block)
|
||||
st = false
|
||||
if block
|
||||
self.each{|val|
|
||||
if block.call(val)
|
||||
st = true
|
||||
break
|
||||
return true
|
||||
end
|
||||
}
|
||||
else
|
||||
self.each{|val|
|
||||
if val
|
||||
st = true
|
||||
break
|
||||
return true
|
||||
end
|
||||
}
|
||||
end
|
||||
st
|
||||
false
|
||||
end
|
||||
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user