Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将命令传递wget给 Ruby 的system方法(第二个版本,它不会将命令传递给 shell。)但是,参数的数量(要下载的网站)取决于用户想要什么。有没有办法做类似的事情,将一个带有任意数量参数的参数数组传递[site1 site2 ...]给这个方法?
wget
system
[site1 site2 ...]
*调用方法(包括方法)时,可以在数组前面使用splat 运算符来扩展它system。
*
sites = %w< site1 site2 ... > system 'wget', *sites