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