将数组数组转换为字符串数组

时间:2021-05-26 21:14:20

I currently have an array of arrays. There are 10 single-item arrays in my overall array

我目前有一个数组数组。我的整个数组中有10个单项数组

[["http://instagr.am/r/123"],["http://instagr.am/r/456"]....]

[[ “http://instagr.am/r/123”],[ “http://instagr.am/r/456”] ....]

My goal is to clean this up so that it is an array of strings.

我的目标是清理它,以便它是一个字符串数组。

Ex:

例如:

[http://instagr.am/r/123, http://instagr.am/r/456, ... ]

[http://instagr.am/r/123,http://instagr.am/r/456, ...]

I have been racking Google trying to find a solution for this but I seem to be unable to find one and I was hoping that you kind folks could help out an emerging Rubyist.

我一直在努力为谷歌寻找解决方案,但我似乎无法找到一个,我希望你善良的人可以帮助一个新兴的Rubyist。

2 个解决方案

#1


18  

Array#flatten

阵列#压平

[["http://instagr.am/r/123"],["http://instagr.am/r/456"]....].flatten

#2


2  

array.map(&:first)

...............

...............

#1


18  

Array#flatten

阵列#压平

[["http://instagr.am/r/123"],["http://instagr.am/r/456"]....].flatten

#2


2  

array.map(&:first)

...............

...............