Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Set#hash
() -> ::Integer
hash → integer
set.c
View on GitHub ↗
static VALUE
set_i_hash(VALUE set)
{
st_index_t size = RSET_SIZE(set);
st_index_t hval = rb_st_hash_start(size);
hval = rb_hash_uint(hval, (st_index_t)set_i_hash);
if (size) {
set_iter(set, set_hash_i, (VALUE)&hval);
}
hval = rb_st_hash_end(hval);
return ST2FIX(hval);
}
Returns the integer hash value for self.
Two sets with the same content have the same hash value.
Example
Set[0, 1].hash == Set[1, 0].hash # => true Set[0, 1].hash == Set[0].hash # => false