End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Set#keep_if
keep_if() { |o| ... }
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/set.rb, line 397
def keep_if
block_given? or return enum_for(__method__) { size }
# @hash.keep_if should be faster, but using it breaks the order of
# enumeration in subclasses.
reject { |o| yield o }.each { |o| @hash.delete(o) }
self
end
Deletes every element of the set for which block evaluates to false, and returns self. Returns an enumerator if no block is given.