5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

2つの配列からhashを作る方法

Posted at

仕事で2つの配列を組み合わせて配列型を作るにはどうすればいいんだと悩んだので、シェアします。

もっとより良い書き方があったら教えて頂ければ幸いです。

numbers = [1,2,3]
words = ['apple','banana','grape']

numbers.zip(words).to_h
=> {1=>"apple", 2=>"banana", 3=>"grape"}
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?