From: Garance A Drosehn Date: 2007-02-14T11:44:30+09:00 Subject: Re: Jumping to "the next one" in something#each ------=_Part_47066_11682581.1171421068004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/10/07, ara.t.howard@noaa.gov wrote: > > On Sat, 10 Feb 2007, Garance A Drosehn wrote: > > Besides, I wanted something which works for *any* routine which > > takes a code-block, not just objects of type Array. How could you > > make that work for the each_pair method of Hash objects? > > this pattern will work with most nearly any method > > harp:~ > cat a.rb > require 'thread' > > argv = %w( -v 4 -l log foobar ) > > q = SizedQueue.new 1 > done = Object.new.freeze > t = Thread.new{ argv.each{|arg| q.push arg}; q.push done } Hmm. Well, I'm not used to even thinking of threads unless I'm doing some kind of classic parallel processing problem (and I almost never need to do those!), but I can see how that tactic could do the job as a solution. I'll have to think about this and some of the other solutions offered, and see what "feels right" for what I'd like to do. (whatever that means!) Thanks for the ideas. -- Garance Alistair Drosehn = drosihn@gmail.com Senior Systems Programmer Rensselaer Polytechnic Institute; Troy, NY; USA ------=_Part_47066_11682581.1171421068004--