From: Oliver Saunders Date: 2008-07-11T11:03:04+09:00 Subject: Re: Map with &:method_name ara.t.howard wrote: > On Jul 10, 2008, at 3:11 PM, Oliver Saunders 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/ OK thanks guys. I found the actual definition: class Symbol def to_proc Proc.new { |*args| args.shift.__send__(self, *args) } end end -- Posted via http://www.ruby-forum.com/.