From: Robert Feldt Date: 2003-09-16T05:55:08+09:00 Subject: Re: performance and style advice requested Robert Klemme skrev den Tue, 16 Sep 2003 05:08:35 +0900: >> def fact(n) >> @facts[n] ||= (@facts.length..n).inject(@facts.last) {|f, i| @facts[i] = > i * f} >> end > > And, I think there's a subtle bug with the inject parameter. Another > version: > > def fact(n) > @facts ||= [0,1] > @facts[n] ||= (@facts.length..n).inject(@facts[-1]) {|f, i| @facts[i] = i > * f} > end > Can you spell it out for me? I fail to see the difference. And I wouldn't do the initial assignment inside the method when we're discussing performance... Regards, /Robert