# Map with &:method\_name

**URL:** <https://www.ruby-forum.com/t/map-with-method-name/142736>\
**Category:** Ruby\
**Created:** [July 10, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/map-with-method-name/142736 "2008-07-10T23:15:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/fbc32d/32.png) [@ole](https://www.ruby-forum.com/u/ole)\
**Post date:** [July 10, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/map-with-method-name/142736/1 "2008-07-10T23:15:26Z")

</div>

I see this a lot but it doesn’t work for me in IRB. Is a gem required or  
something?

> > [1,2,3].map(&:to\_s)  
> > TypeError: wrong argument type Symbol (expected Proc)  
> > from (irb):2

---

<div class="post-metadata">

**Author:** ![ole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/fbc32d/32.png) [@ole](https://www.ruby-forum.com/u/ole)\
**Post date:** [July 10, 2008, 11:28pm UTC](https://www.ruby-forum.com/t/map-with-method-name/142736/2 "2008-07-10T23:28:00Z")

</div>

On Jul 10, 2008, at 3:11 PM, Oliver S. wrote:

> I see this a lot but it doesn’t work for me in IRB. Is a gem  
> required or  
> something?
> 
> > > [1,2,3].map(&:to\_s)  
> > > TypeError: wrong argument type Symbol (expected Proc)  
> > > from (irb):2

it’s rails - basically

class Symbol  
def to\_proc  
sym = self  
lambda{|obj| obj.send sym}  
end  
end

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![ole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/fbc32d/32.png) [@ole](https://www.ruby-forum.com/u/ole)\
**Post date:** [July 11, 2008, 12:41am UTC](https://www.ruby-forum.com/t/map-with-method-name/142736/3 "2008-07-11T00:41:43Z")

</div>

On Thu, Jul 10, 2008 at 5:22 PM, ara.t.howard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > 
> 
> end

And it’s been picked up in Ruby 1.9, and maybe 1.8.7 as well since the  
current draft of the Pickaxe 3rd ed doesn’t label it as 1.9 only.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![ole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/fbc32d/32.png) [@ole](https://www.ruby-forum.com/u/ole)\
**Post date:** [July 11, 2008, 4:07am UTC](https://www.ruby-forum.com/t/map-with-method-name/142736/4 "2008-07-11T04:07:10Z")

</div>

ara.t.howard wrote:

> On Jul 10, 2008, at 3:11 PM, Oliver S. wrote:
> 
> > I see this a lot but it doesn’t work for me in IRB. Is a gem  
> > required or  
> > something?
> > 
> > > > [1,2,3].map(&:to\_s)  
> > > > TypeError: wrong argument type Symbol (expected Proc)  
> > > > from (irb):2
> 
> it’s rails - basically
> 
> class Symbol  
> def to\_proc  
> sym = self  
> lambda{|obj| obj.send sym}  
> end  
> end
> 
> a @ [http://codeforpeople.com/](http://codeforpeople.com/)

OK thanks guys. I found the actual definition:

class Symbol  
def to\_proc  
Proc.new { |\*args| args.shift. **send** (self, \*args) }  
end  
end
