From: Konrad Meyer Date: 2007-11-05T14:30:49+09:00 Subject: Re: def blah do |x| -- alternate method definition syntax --nextPart3894629.T9HGC1DLsu Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth Joe Holt: > Hi all, >=20 > This came up in a discussion about Ruby with a friend who is learning... >=20 > Why aren't method definitions more like blocks? Perhaps it's easier to =20 > explain with some examples. Consider the method blah: >=20 > def blah(x) > ... > end >=20 > And this proc: >=20 > lambda do |x| > ... > end >=20 > Friend wondered why a method definition couldn't be like this: >=20 > def blah do |x| > ... > end >=20 > And I didn't have a good answer, except that "it just is." Maybe I =20 > could have gone into the semantic difference between methods and =20 > lambda procs, but does semantic difference necessitate syntactic =20 > difference? >=20 > I tried to simulate this like so: >=20 > blah =3D lambda do |x| > ... > end >=20 > Which I realize is going down a different path, but still. Now I wish =20 > I could do this: >=20 > blah(5) >=20 > But I can't. I have to blah.call. >=20 > I'm not complaining at all. This isn't bait. It's just me loving Ruby =20 > and wondering aloud. Any opinions? >=20 > Joe blah.call(5) is synonymous with blah[5], IIRC. HTH, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart3894629.T9HGC1DLsu Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHLqqECHB0oCiR2cwRAtLJAKCIQteF1Uga1SgewAAXExVOTjGzCgCfaAT4 GhfY5gLQWCjQaiTtmQvhxN8= =loaC -----END PGP SIGNATURE----- --nextPart3894629.T9HGC1DLsu--