From: Jim Freeze Date: 2005-07-06T13:08:53+09:00 Subject: Re: yield does not take a block * Florian Frank [2005-06-30 13:31:23 +0900]: > Adam P. Jenkins wrote: > > >obj.method_that_takes_two_blocks {|a| ... }, {|b| ...}, third_arg > > It is made that way in current Ruby 1.9: > > >> def compose(f, g) { |x| f[g[x]] } end > => nil > >> h = compose({ |x| 2 * x }, { |x| x + 1 }) > => # > >> h[3] > => 8 Well, this does not appear to be that new. 1.8.2 does the same, it just requires the 'lambda' keyword: def compose(f, g) lambda { |x| f[g[x]] } end h = compose(lambda { |x| 2 * x }, lambda { |x| x + 1 }) h[3] #=> 8 However, even with the removal of lambda keyword, I think that there is a big difference between the 'attached' block and a block that is just another argument. meth( {...}, {...}, ...) is very different from: meth {...} {...} ... As has been said before, changing to the former, to get multiple blocks, will change the way ruby is used and perceived by developers. And I don't think it would be for the better. -- Jim Freeze