rubyzip 辅导
Zip::ZipOutputStream.open(folderpath) do |z|
z.print IO.read(folderpath)
在上面的代码中,我有 Zip::ZipOutputStream.open(file_path) do |z|
。我不明白,|z|
是什么意思? |z| 是什么意思?参考?例如,我可以更改|z|吗?对于其他,例如 |changez| ?
我在这里得到了完整的代码 http://blog.devinterface.com/2010/ 02/create-zip-files-on-the-fly/ 但我无法理解 do |z| 的第一行。
Zip::ZipOutputStream.open(folderpath) do |z|
z.print IO.read(folderpath)
In the code above, I have Zip::ZipOutputStream.open(file_path) do |z|
. I do not understand, what the do |z|
mean? What does |z| refer to? Can I for example change |z| to other, example is |changez| ?
I got the complete code here
http://blog.devinterface.com/2010/02/create-zip-files-on-the-fly/ but I can not undestand the 1st line of do |z| .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
||
中的任何内容,都被视为接下来的匿名方法(或 lambda 表达式)的参数,例如:
可以重写为
|n|可以是任何东西,只是变量的名称。
whatever comes inside
||
, considered to be the parameters for the anonymous method (or lambda expression) that comes next,for ex:
can be rewritten as
|n| could be anything, just a name for a variable.