From: Ezra Zygmuntowicz Date: 2006-10-19T13:34:18+09:00 Subject: Re: whats this lambda code doing? On Oct 18, 2006, at 9:08 PM, Morton Goldberg wrote: > On Oct 18, 2006, at 10:48 PM, Ezra Zygmuntowicz wrote: > >> What it is doing with the inject is essentially building up a >> block with multiple procs inside it and then calling that. So the >> block that gets called looks something like this by the time it >> gets call'ed: >> >> lambda { >> lambda { Foo.with_block hash, &blk } >> lambda { Bar.with_block hash, &blk } >> lambda { Baz.with_block hash, &blk } >> }.call > > Maybe I'm being even more dense than usual, but I can't accept > that. It wouldn't produce the observed print-out order. I think it > must be more like: > > lambda { Baz.with_block(hash, > lambda { Bar.with_block(hash, > lambda { Foo.with_block(hash, &blk) }) }) }.call > > Regards, Morton > Ahh yes you are totally correct. See? It is tricky code ;) -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)