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.
a = [1, 2, 3] b = [4, 5, 6]
2D 配列で 2 つの配列を結合するにはどうすればよいですか?:
[[1, 4], [2, 5], [3, 6]]
Array#zip を試す
a.zip(b) => [[1,4],[2,5],[3,6]]
明らかにzip最も簡単な答えですが、これも機能します。
zip
[a, b].transpose => [[1, 4], [2, 5], [3, 6]]