Count the number of items that meet either one condition or another:
items.count do |item|
next true unless first_test?(item)
next true unless second_test?(item)
false
end
count
means you don't have to do i = 0
and i += 1
.
next
means that you can finish that iteration of the block and still supply the answer, rather than hanging around until the end.
(If you wanted, you could replace the last two lines of the block with the single line ! second_test?(item)
, but that'd make it look messier)