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 = [["A", "B"], ["323", "32"]]
现在我希望能够以它显示的方式格式化这个数组
A = 323 B = 32
我该怎么做 ?
谢谢
您正在寻找Array#transpose,我相信:
Array#transpose
> a = [["A", "B"], ["323", "32"]] => [["A", "B"], ["323", "32"]] >> a.transpose => [["A", "323"], ["B", "32"]]
(0...a.first.length).each{|i| puts "#{a[0][i]} = #{a[1][i]}"}