[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Finding help

Chris Carter

2/9/2007 3:09:00 PM

On 2/9/07, Luke Ivers <technodolt@gmail.com> wrote:
> I'm wanting to figure out what the &: syntax does, but I'm not exactly sure
> how to search for it given that it contains special characters... a search
> on google for "ruby &:" doesn't really give me anything worth looking at,
> and I just checked through the first edition of the Pickaxe (I don't own the
> second edition), and couldn't find anything in there, either (although,
> sometimes I miss really obvious things, so I suppose it's possible I just
> missed it in there).
>
> If someone could either explain it to me, or point me in the direction of
> something that explains it, I would greatly appreciate it.
>
> (And I also tried searching on ruby-forum.org for &:... it returns
> "Application Error")
>
> Thanks.
>
Hi Luke,
The &: syntax is the famous Symbol#to_proc hack. The & operator calls
#to_proc on the object it is connected to, in this case a Symbol.
This isn't in Ruby core, but it is in Rails, and a bunch of extension
frameworks. Essentially it takes the first argument passed to it, and
runs the method that was passed in symbol form.

http://sn.oplo.ws/index.php?title=Symb...

--
Chris Carter
concentrationstudios.com
brynmawrcs.com

5 Answers

Luke Ivers

2/9/2007 3:58:00 PM

0

Chris Carter wrote:
> On 2/9/07, Luke Ivers <technodolt@gmail.com> wrote:
>>
>> (And I also tried searching on ruby-forum.org for &:... it returns
>> "Application Error")
>>
>> Thanks.
>>
> Hi Luke,
> The &: syntax is the famous Symbol#to_proc hack. The & operator calls
> #to_proc on the object it is connected to, in this case a Symbol.
> This isn't in Ruby core, but it is in Rails, and a bunch of extension
> frameworks. Essentially it takes the first argument passed to it, and
> runs the method that was passed in symbol form.
>
> http://sn.oplo.ws/index.php?title=Symb...

Wow.

I just had one of those moments where a minor little thing causes a
gigantic shift in my perceptions. That is just freakin cool!

--
Posted via http://www.ruby-....

Luke Ivers

2/9/2007 4:01:00 PM

0

> This isn't in Ruby core, but it is in Rails, and a bunch of extension
> frameworks.

Is there a specific reason for this (it not being in core)? It seems
like a quite useful functionality, and, although I am admittedly rather
new at this, I don't see what problems it would cause to include it.

Man... I understand exactly what a lambda is now, I understand inject's
usefulness better, and I had no idea that doing '&<blah>' called
<blah>.to_proc

Sweet.

--
Posted via http://www.ruby-....

Florian Frank

2/9/2007 4:10:00 PM

0

Luke Ivers wrote:
> Is there a specific reason for this (it not being in core)?

It's in 1.9.

--
Florian Frank

Luke Ivers

2/9/2007 4:16:00 PM

0

Florian Frank wrote:
> Luke Ivers wrote:
>> Is there a specific reason for this (it not being in core)?
>
> It's in 1.9.

Much obliged.

Is there a ruby core timeline I can look at (ie. when they plan on
releasing new minor and/or major versions), or is it just kind of mutual
decision by core comitters at any given time?

--
Posted via http://www.ruby-....

Keith

12/19/2010 9:43:00 PM

0

In article
<aa492f6c-1116-4238-acfb-af9cddfe5d9c@j19g2000prh.googlegroups.com>,
Curt <obadiahlynch@gmail.com> wrote:

> I'm not sure I want to integrate our currency with Mexico's, with
> Mexico in its current state.

Anything like that is a long way off. It would most likely occur with
Canada first and then bring in other countries.

--
Best Regards, Keith
http://home.comcast.net/~kilo...