From: George Ogata Date: 2007-02-18T21:17:37+09:00 Subject: Re: exit in a bloc DRY way... On 2/18/07, SonOfLilit wrote: > > On 2/18/07, Sharon Phillips wrote: > > Hi, > > > > I think this should do the job > > nb-=1 if contact.select{|c| c==parameter}.any? > > > > it will return nb-1 if any contact matches parameter, or nil if none > > match > > > > cheers, > > Dave > Isn't #find better than #select? > > select wouldn't break the first time a match was found, find would. > Less time, less memory. > > Aur Saraf I'd do: nb-=1 if contact.any?{|c| c.from==parameter} Regards, George.