From: Terry Poulin Date: 2007-09-27T08:50:13+09:00 Subject: Re: Favorite idiom for "keep doing this until it returns nil/false" Phrogz wrote: > I want to keep running gsub! on a string until it returns nil. How do > you prefer to do this? > > true while str.gsub!( ... ) > > while str.gsub!( ... ); end > > begin > done = !str.gsub!( ... ) > end until done > > begin > made_replacement = str.gsub!( ... ) > end while made_replacement > > ...some other way? > > > Having been *gotten* accustomed to the while (!expr) { do_this(); } way of writing things, I would probably use this in ruby: until str.gsub!( ... ) end Generally, I write what ever I feel works when I am testing. The try to refine it into as clear and concise a manor as I can before I finish the prototype. TerryP. -- Email and shopping with the feelgood factor! 55% of income to good causes. http://www.ippimail.com