Ruby数组到字符串的转换

Shi*_*man -1 ruby arrays

我在一个数组中有一堆URL链接,例如,

urls = [["www.google.com"], ["www.yahoo.com"]]
#I want the urls variable to be like this below
urls = ["google.com", "www.yahoo.com"]
#I want to break up the sub-arrays in urls.
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

Nab*_*eel 7

array#flatten像这样使用

> urls = [["www.google.com"], ["www.yahoo.com"]]
#=> [["www.google.com"], ["www.yahoo.com"]]
> urls.flatten
#=> ["www.google.com", "www.yahoo.com"]
Run Code Online (Sandbox Code Playgroud)