Sha256: 5d11da184edf3ab7a25a7fe45ebecd0b78b7ab244ae325df3300df3c8d9b52fd
Contents?: true
Size: 506 Bytes
Versions: 20
Compression:
Stored size: 506 Bytes
Contents
# frozen_string_literal: true Array.class_eval do # 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
Version data entries
20 entries across 20 versions & 1 rubygems