End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Set#subset?
subset?(set)
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/set.rb, line 435
def subset?(set)
case
when set.instance_of?(self.class) && @hash.respond_to?(:<=)
@hash <= set.instance_variable_get(:@hash)
when set.is_a?(Set)
size <= set.size && all? { |o| set.include?(o) }
else
raise ArgumentError, "value must be a set"
end
end
Returns true if the set is a subset of the given set.