Sha256: c9706329d3cb591db75b63bb555b97e46cb88f383b92aa6228f8f7153014e5d7
Contents?: true
Size: 584 Bytes
Versions: 6
Compression:
Stored size: 584 Bytes
Contents
# 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
Version data entries
6 entries across 6 versions & 1 rubygems