Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
2つの配列を使用して新しいハッシュオブジェクトを作成する必要があります。
ただし、条件は、最初の配列値がハッシュのキー値であり、2番目の配列値がハッシュ値である必要があることです。
a = ["x", "y"] b = [2, 4]
結果は次のようになります。c = {"x" => 2, "y" => 4}
c = {"x" => 2, "y" => 4}
irb(main):001:0> a = ["x", "y"]; b = [2, 4] => [2, 4] irb(main):002:0> Hash[a.zip(b)] => {"x"=>2, "y"=>4}