@main = connection.execute("select code_ver, comment from mastertest
@main 包含这样的内容:
{ [2.1, abcd],
[3.0, xyz],
[2.0, pqr] }
我想将此数组拆分为 2 个数组,以便:
@arr1 = {[2.1],
[3.0],
[2.0]}
@arr2 = {[abcd],
[xyz],
[pqr]}
我做这样的事情来从另一个数组复制一个数组:
@arr1 = Array.new
@main.each { |r| @arr1.push(r[0]) }
Can something be done here itself to split it how I want it?