# frozen_string_literal: true Array.class_eval do unless method_defined?(:only_some?) # Same as `my_array.any?(&block) && !my_array.all?(&block)` # # @return [Boolean] # def only_some?(*meth_args) # Check arg size since `any?` arg take presence over block return any?(*meth_args) && !all?(*meth_args) if meth_args.size.positive? any = false all = true each do |*args| result = yield(*args) any ||= result all &&= result break if any && !all end return any && !all end end end