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| .
whatever comes inside ||
, considered to be the parameters for the anonymous method (or lambda expression) that comes next,
for ex:
(1..3).each do |n|
puts n
end
can be rewritten as
(1..3).each {|n| puts n}
|n| could be anything, just a name for a variable.