From: Phrogz Date: 2007-03-28T08:10:05+09:00 Subject: Re: Knocking Lines Out Of A Multiline String On Mar 27, 10:12 am, "Rick DeNatale" wrote: > On 3/26/07, Phrogz wrote: > > > On Mar 23, 12:39 pm, "Rick DeNatale" wrote: > > > str.reject {|s| Regexp.new("/usr/local/lib").match(s)} > > > Note that the above results in Regexp#new being called for each line > > in the string; not very efficient: > > Quoting my old friend Kent Beck: > > "Make it run before you make it fast." On the one hand: "Premature optimization is the root of all evil"[1] On the other - knowing that calling a constructor on each iteration of a block is much slower when a literal doesn't change - and when it's less characters to type as well - might be considered not so much premature optimization as...well...reasonable code planning. [1] http://hans.gerwitz.com/2004/08/12/premature-optimization-is-the-root-of-all-evil.html