%w(array) 是什么意思? [英] What does %w(array) mean?
本文介绍了%w(array) 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在查看 FileUtils 的文档.
I'm looking at the documentation for FileUtils.
我对以下行感到困惑:
FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
%w
是什么意思?你能指出我的文档吗?
What does the %w
mean? Can you point me to the documentation?
推荐答案
%w(foo bar)
是 ["foo", "bar"]
的快捷方式.这意味着编写由空格而不是逗号分隔的字符串数组是一种表示法,并且在它们周围没有引号.您可以在 zenspider 的 quickref 中找到一系列书写文字的方法.
%w(foo bar)
is a shortcut for ["foo", "bar"]
. Meaning it's a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can find a list of ways of writing literals in zenspider's quickref.
这篇关于%w(array) 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文