From: Tim Hunter Date: 2007-12-08T10:14:48+09:00 Subject: Re: Completely dumb iterator question from a newbie Steckly, Ron wrote: > inbox.Items.each do |message| > message.Attachments.each do |attachment| > filename = "c:\\attachments\\#{attachment.FileName}" > attachment.SaveAsFile(filename) > File.delete(filename) if File.size(filename) < 500000 > end > end > ... > > The thing that's bothering me is where people decide the thing to > iterate over. How do you decide what to put between the pipes | |? > There's no magic about the word "message". It's just a variable name. You get to pick it. The magic is that the each method goes through each (aha! that's why it's called "each") element in inbox.Items and assigns the element to the variable you named between the pipes. Of course, once you pick a name to use you have to use it consistently. If you used "msg" between the pipes, you have to use "msg" instead of "message" throughout the code between do and end. -- RMagick: http://rmagick.rubyforge.org/