From: "Michael T. Richter" Date: 2008-05-23T16:07:32+09:00 Subject: Re: Lambda Block vs. Method --=-EpQgxaTS6614f/spCWPR Content-Type: multipart/alternative; boundary="=-Idj2MBwJy6YNo2p00bnH" --=-Idj2MBwJy6YNo2p00bnH Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > > You can pass a lambda or proc to another method, which you can't > > exactly do with a method (you can get most of the same effect by > > passing the method on which the method is defined and the method name, > > and calling the method that way.)=20 > Actually, you can pass a method to another method using the method > method. ;) >=20 > def method_caller(method, *args) > method.call(*args) > end >=20 > a_method =3D method(:puts) > method_caller(a_method, "foo") All these gyrations. Wouldn't it just be simpler to give Ruby first-class functions? --=20 Michael T. Richter (GoogleTalk: ttmrichter@gmail.com) When debugging, novices insert corrective code; experts remove defective code. (Richard Pattis) --=-Idj2MBwJy6YNo2p00bnH Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
> You can pass a lambda or proc to another metho=
d, which you can't
> exactly do with a method (you can get most of =
the same effect by
> passing the method on which the method is defi=
ned and the method name,
> and calling the method that way.) 

Actually, you can pass a method to another method u=
sing the method
method. ;)

def method_caller(method, *args)
  method.call(*args)
end

a_method =3D method(:puts)
method_caller(a_method, "foo")

All these gyrations.  Wouldn't it just be simpler to give Ruby first-c= lass functions?

--
Michael T. Richter <ttmri= chter@gmail.com> (GoogleTalk: ttmrichter@gmail.com)
When debugging, novices insert corrective code; experts remove defective= code. (Richard Pattis)
--=-Idj2MBwJy6YNo2p00bnH-- --=-EpQgxaTS6614f/spCWPR Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBINm0mLqyWkKVQ54QRAvYUAJ9ARim2VGV4jRqMd2+aaqArPZ17swCfUjeG V+Uc8ozrY9hyO2kB2kYFkcw= =vB1S -----END PGP SIGNATURE----- --=-EpQgxaTS6614f/spCWPR--