From: James Gray Date: 2008-10-29T02:58:12+09:00 Subject: Re: memoization example the ruby programming language question On Oct 28, 2008, at 11:32 AM, Hiro Protagonist wrote: > Hi all, Hello. > Attached is the example of memoization from the above book. > I marked the line that I don't understand. I want an explanation in > terms of syntax. OK, lambda() is just the tool that creates the Proc object for you. You call memoize() on that to turn it into a meomized Proc. > If cache has data why is method memoize called first? The memoize() method is called on a Proc, to transform it into a memoized Proc. From then on, you get the cached magic when you use it. > This example may use some ruby 1.9 syntax. I think factorial[x-1] > is equivalent to factorial.call(x-1). That's valid in Ruby 1.8 as well. Hope that helps explain things. James Edward Gray II