From: Chris Carter Date: 2007-02-10T00:09:23+09:00 Subject: Re: Finding help On 2/9/07, 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. > 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 -- Chris Carter concentrationstudios.com brynmawrcs.com