From: Robert Klemme Date: 2009-12-07T18:13:46+09:00 Subject: Re: closures 2009/11/28 Florian Gilcher : > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On a sidenote, Ruby 1.9 also has this cool function: > >  f = ->(a,b){ a + b } >  c = f.curry >  b = c[1] > > where b is a partially applied function, with a bound to 1. > >  b[6] #=> a + b = 7 > > then evaluates the whole function. The cool thing is that the result of f.curry can be used to curry the function as well as to evaluate it - depending on the number of arguments: irb(main):001:0> f = ->(a,b){ a + b } => # irb(main):002:0> f[1,2] => 3 irb(main):003:0> c = f.curry => # irb(main):004:0> c[1,2] => 3 irb(main):005:0> b = c[1] => # irb(main):006:0> b[2] => 3 irb(main):007:0> > P.S.: I still think it should be called #schönfinkeln. LOL Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/