I'm not so sure what you are trying to do here.  It looks like you are
returning a combination of a class instance and a function.

You could clearly write a class that had instances called to  do such a
thing

so you have

x = MyClass.new(:sum)

y = x.doit(4)

z = y.doit(3,5)

Is that what you mean?

Ralph


----- Original Message -----
From: "MikkelFJ" <mikkelj-anti-spam / post1.dknet.dk>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>; <undisclosed-recipients:>
Sent: Friday, November 30, 2001 2:15 PM
Subject: [ruby-talk:27010] Re: first class functions in Ruby


>
> "Ralph Mason" <ralph.mason / telogis.com> wrote in message
> news:135701c1792a$679ffc90$0101a8c0 / p3...
> > irb(main):010:0> def sq(x)
> > irb(main):011:1> x+x
> > irb(main):012:1> end
> > nil
> > irb(main):013:0> def aMes(f)
> > irb(main):014:1> send(f,42) + send(f,27)
> > irb(main):015:1> end
> > nil
> > irb(main):016:0> aMes :sq
> > 138
> > irb(main):017:0>
> >
>
> That is nice. It has the same level of compactness that I asked for.
> The :sq handles the problem of delayed evalution.
> I'd still like to be able to simply apply the parameters:
>   f(42)
> but it isn't too bad.
> What remains then is partial evaluation:
>
> def sum(a, b)
>   a + b
> end
>
> plus4 = send(:sum, 4)
> send(plus4, 8)
> ==> 12
>
> Currently you get an argument count exception instead of a new function
with
> fewer arguments. A nice to have...
>
>
> MikkelFJ
>
>
>
>
>