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] 
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 = -> 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 = and -> just doesn't sit well with most of us.

   twotimes = \x { 2 * x }

reads better to me, as does

   twotimes = fn x -> { 2 * x }

as does

   twotimes = x -> { 2 * x }

and

   twotimes = lambda {|x| 2 * x }


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

   n_times = { |n=2|   {|val| n*val}}

   twotimes = n_times[2]
   twotimes[3]



Dave