Forum: Ruby Finding help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2017657725dd1bce83dc8a1e2e991d04?d=identicon&s=25 Luke Ivers (Guest)
on 2007-02-09 16:05
(Received via mailing list)
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.
0f7716186bac5a8a2dc8007b70928c06?d=identicon&s=25 Luke Ivers (technodolt)
on 2007-02-09 16:09
Luke Ivers 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.

And, I think I just figured it out... it's using a symbol to reference a
function, and an & to turn it into a block?  Then you can send a
function (wrapped in a closure) to another function expecting a block?
96931bfe0c2948f47a98e15ae52e5637?d=identicon&s=25 Chris Carter (cdcarter)
on 2007-02-09 16:10
(Received via mailing list)
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=Symbol#to_proc
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2007-02-09 16:16
(Received via mailing list)
You might find this blog helpful:

http://jayfields.blogspot.com/2007/01/ruby-invokin...
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2007-02-09 16:17
(Received via mailing list)
btw, for further searches you should also check out the Ruby kitchen
sink:

http://rubykitchensink.ca/

It searches Ruby/Rails pages only (currently about 10.000 of them, and
still growing) so it might give you more relevant results.

Cheers,
Peter

__
http://www.rubyrailways.com :: Ruby and Web2.0 blog
http://scrubyt.org :: Ruby web scraping framework
0f7716186bac5a8a2dc8007b70928c06?d=identicon&s=25 Luke Ivers (technodolt)
on 2007-02-09 16:57
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=Symbol#to_proc

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!
0f7716186bac5a8a2dc8007b70928c06?d=identicon&s=25 Luke Ivers (technodolt)
on 2007-02-09 17:00
> 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.
D84df7c68f790e492c4ad4ec5fe65547?d=identicon&s=25 Florian Frank (Guest)
on 2007-02-09 17:10
(Received via mailing list)
Luke Ivers wrote:
> Is there a specific reason for this (it not being in core)?

It's in 1.9.
0f7716186bac5a8a2dc8007b70928c06?d=identicon&s=25 Luke Ivers (technodolt)
on 2007-02-09 17:15
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?
This topic is locked and can not be replied to.