From: Gregory Brown Date: 2009-05-14T11:52:29+09:00 Subject: Re: [bikeshed] Syntactic sugar idea On Wed, May 13, 2009 at 10:42 PM, Daniel DeLorme wrote: > It seems that often an object will be passed into a block only to invoke > a method of that object: >  arr.map{ |obj| obj.some_method } > > So I had the (weird? stupid?) thought that it would be nice to have some > syntactic sugar like this: >  arr.map{ .some_method } > > Does that make any sense? >> RUBY_VERSION => "1.9.1" >> %w[foo bar baz].map(&:upcase) => ["FOO", "BAR", "BAZ"] On Ruby 1.8.6, you can implement this easily as: class Symbol def to_proc lambda { |x| x.send(self) end end -greg -- BOOK: http://rubybestpractices.com TECH: http://blog.majesticseacreature.com NON-TECH: http://metametta.blogspot.com