Hello,
 It seems that you are the winner of the code simplification grand =
prize. I wonder how we can use that with the method def syntax. Good =
day.

Yemi Bedu

P&R Fasteners
325 Pierce St
Somerset, NJ 08873
732-302-3600
-----Original Message-----
From: Dave Thomas [mailto:dave / pragprog.com]=20
Sent: Monday, May 26, 2008 12:11 PM
To: ruby-core / ruby-lang.org
Subject: Re: [PATCH] lambda with normal block syntax


On May 26, 2008, at 11:01 AM, Yukihiro Matsumoto wrote:

>
> You should read
>
>  twotimes =3D -> x {2 * x}
>
> as "twotimes is 2 times x where x is not yet assigned", here -> works
> as incomplete left to right assignment operator.  So,

I think we're all comfortable with the concept--it's just the notation.

The juxtaposition of =3D and -> just doesn't sit well with most of us.

   twotimes =3D \x { 2 * x }

reads better to me, as does

   twotimes =3D fn x -> { 2 * x }

as does

   twotimes =3D =EB x -> { 2 * x }

and

   twotimes =3D lambda {|x| 2 * x }


In fact, given a change that allows block arguments to be like method =20
arguments, then maybe no other change is needed. We can always alias =20
lambda to something shorter, and then everyone is happy

   n_times =3D =EB { |n=3D2|   =EB {|val| n*val}}

   twotimes =3D n_times[2]
   twotimes[3]



Dave