Ruby 4.0 リファレンスマニュアル

instance method Set#hash

hash -> Integer[permalink][rdoc][edit]

self のハッシュ値を返します。

同じ要素を持つ集合は、要素の順序にかかわらず同じハッシュ値を返します。そのため、Set を Hash のキーとして使えます。

例
p Set[1, 2].hash == Set[2, 1].hash # => true
h = {Set[1, 2] => :a}
p h[Set[2, 1]]                      # => :a

[SEE_ALSO] Set#eql?, Object#hash