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つのアレイを持っています、
a = [1, 2] b = [:a]
結果を次のように取得したい
[[1, :a], [2, :a]]
このための方法はありますか?
Array#productを使用します:
a = [1, 2] b = [:a] a.product(b) => [[1, :a], [2, :a]]
また、あなたはこのようにそれを行うことができます
[a,b*a.size].transpose #=> [[1, :a], [2, :a]]