I have an array of strings (actually file names), something like
filenames = ['file1.jpg', 'file2.jpg', 'file3.jpg']
The method I am calling expects something like
images = Magick::ImageList.new("image1.png", "image2.png", "image3.png")
but if I call as below, I am actually passing an array.
images = Magick::ImageList.new(filenames)
How do I unwrap the contents of the array?
Do as below using splat opearator(*) :
images = Magick::ImageList.new(*filenames)
As @Stefan mentioned the documentation link for the same Array to Arguments Conversion
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.