From: Ben Giddings Date: 2003-09-15T22:35:14+09:00 Subject: Re: performance and style advice requested Robert Feldt wrote: > Fourth is some minor changes to use common Ruby idioms. > > So my version is: > > module Comb > # memoize results for speed > FactMemo, CombMemo = [1, 1, 2, 6, 24, 120, 720], {} > > # factorial > def Comb.fact(n) > return 0 if n < 0 > FactMemo[n] ||= (n * fact(n-1)) > end I like the fact you wrapped the functionality in a module, but if we're using Ruby idioms, the FactMemo and CombMemo variables should really not be named with leading uppercase letters. They look like classes (or constants) and may be treated as such by Ruby. I'd recommend instead fact_memo and comb_memo. Ben