###ハッシュから配列
to_aメソッド
ruby
money = { japan: 'yen', us: 'dollar', india: 'rupee' }
money.to_a #=> [[:japan, "yen"], [:us, "dollar"], [:india, "rupee"]]
###配列からハッシュ
to_hメソッド
なお、key重複の場合は最後の配列要素を採用する
ruby
money = [[:japan, "yen"], [:us, "dollar"], [:india, "rupee"]]
money.to_h #=> { japan: 'yen', us: 'dollar', india: 'rupee' }
Hash[]
ruby
money = [[:japan, "yen"], [:us, "dollar"], [:india, "rupee"]]
Hash[money] #=> { japan: 'yen', us: 'dollar', india: 'rupee' }
money = [:japan, "yen", :us, "dollar", :india, "rupee"]
Hash[*money] #=> { japan: 'yen', us: 'dollar', india: 'rupee' }