我有以下数组
[["convertible", "2010", "red"], ["convertible", "2010", "green"]]
如何在rails或ruby中将上述数组合并到这个数组中?
["convertible", "2010", "red", "convertible", "2010", "green"]
编辑-1
@category.each do |content|
form_chain = JSON.parse(content.content)
chained_array << form_chain.values
end
chained_array
这就产生了
[["convertible", "2010", "red"], ["convertible", "2010", "green"]]
如果我使用
chained_array.flatten!
它会给出相同的结果。 最佳答案
[["convertible", "2010", "red"], ["convertible", "2010", "green"]].flatten!