Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Set#===
(untyped other) -> bool
===(p1)
set.c
View on GitHub ↗
static VALUE
set_i_include(VALUE set, VALUE item)
{
return RBOOL(RSET_IS_MEMBER(set, item));
}
Alias of #include?
Returns whether the given object is an element of self:
Example
set = Set[0, :zero, '0'] set.include?('0') # => true set.include?('zero') # => false
Tests equality using hash and eql?.
Aliased as ===, which means that sets may be used in case expressions:
Example
case :apple when Set[:potato, :carrot] 'vegetable' when Set[:apple, :banana] 'fruit' else 'unknown' end # => "fruit"
Related: see Methods for Querying.