2010/5/28 Caleb Clausen <vikkous / gmail.com>:
> On 5/27/10, Paul A. <cyril.staff / gmail.com> wrote:
>> Hi,
>>
>> Just a thin post in order to purpose this:
>>
>> I think it could be cool to call lambda function just like: =EB
>>
>> Such as:
>>
>> a =3D 0
>> my_while =A0=EB { a < 5 } =A0do
>> =A0 =A0puts a
>> =A0 =A0a +=3D 1
>> end
>
> Honestly, why is this better than:
>
> =A0a=3D0
> =A0while a<5 do
> =A0 =A0puts a
> =A0 =A0a+=3D1
> =A0end

or even

5.times do |a|
  puts a
end

or even

puts (0...5).to_a

> This way is so much less noisy and more succinct. You could even leave
> off the do.
>
> lambdas should not be used to replace arbitrary expressions. Only
> where you need them.

Yep, fully agree.

> Putting Robert's doubts about encoding issues aside, you can already
> do this in both 1.8 and 1.9:
>
> #encoding: utf-8
> alias =EB lambda
> x=3D=EB{ p :foo }
> x.call #=3D> :foo
>
> In 1.8, you do have to pass -Ku on the command line, tho.

This is cool!  Thanks for that.

> I am with Piyush on the question of how you type these things, tho. My
> keyboard only has ascii on it. I'm putting off adopting unicode until
> a unicode keyboard is available.

You'll need a new desk then, too - and probably a set of arm extensions. :-=
)

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/