-1

此方法接受 URL 列表:

Magick::ImageList.new("img1url", "img2url", "img3url")

我有这个字符串"url1, url2, url3"

如何将上述方法作为单独的参数提供给我的列表?我试过了:

urls = urls.split(',')
Magick::ImageList.new(urls) # fails. It produces an array.

# fails. It produces "'img1url','img2url'".
# The comma is part of the string, but it should split method arguments.
urls = urls.split(',').join("','")
Magick::ImageList.new(urls)
4

1 回答 1

4

*可以将数组扩展为参数:

urls = urls.split(', ')
Magick::ImageList.new(*urls)
于 2013-05-24T14:07:14.943 回答