Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 高效地将数组的数组转换为字符串数组_Ruby On Rails_Arrays - Fatal编程技术网

Ruby on rails 高效地将数组的数组转换为字符串数组

Ruby on rails 高效地将数组的数组转换为字符串数组,ruby-on-rails,arrays,Ruby On Rails,Arrays,我有一个数组 arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]] 我想改变信仰 arr=["Sumit where", "where are", "are you"] 我如何才能高效地完成这项工作试试: arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]] arr = arr.map {|i| i.join(' ') } 它给出[“Sumit”,“where”,

我有一个数组

arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
我想改变信仰

arr=["Sumit where", "where are", "are you"]
我如何才能高效地完成这项工作

试试:

arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
arr = arr.map {|i| i.join(' ') }

它给出[“Sumit”,“where”,“where”,“are”,“are”,“you”]但我想arr=[“Sumit where”,“where are”,“you]没有循环是否可能?
arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]  
v = arr.map { |x| x.join(" ") }  
p v