ただのリファレンスの写経です。
class Hash
Hash#assoc(key)
ハッシュがkeyをキーとして持つとき、キーと値のペアを配列として返す。
hash = { one: 'a', two: 'b', three: 'c' } p hash.assoc(:one) # => [:one, 'a'] p hash.assoc(:two) # => [:two, 'b']
Hash#store(key, value)
keyに対してvalueを関連付ける。
hash = { one: 'a', two: 'b', three: 'c' } hash.store(:four, 'd') p hash # => {:one=>"a", :two=>"b", :three=>"c", :four=>"d"}
Hash#clear
ハッシュの中身を空にする。
hash = { one: 'a', two: 'b', three: 'c' } hash.clear p hash # => {}
感想
どのメソッドも使い道が思い浮かばなかった。