Hello,

On 6/16/06, Yukihiro Matsumoto wrote:

> |irb(main):023:0> [[1,2,3], [4,5,6], [7,8,9]].map &:reverse
> |NoMethodError: undefined method `reverse' for 1:Fixnum
>
> Good point.  The ActiveSupport Symbol#to_proc consider an array as a
> group of a receiver and method arguments.  It was a design choice.
> You need to ask the rationale behind this design to the rails list.
>
> As you've stated, the alternative is making everything a receiver.
> I think either choice is both good and bad.  Personally I prefer the
> latter, it's more consistent.  But compatibility problem would arise.
>
>                                                         matz.


For example, I submitted http://dev.rubyonrails.org/ticket/5295 as follow:

class Symbol
  def to_proc
    Proc.new{|*args| args.shift.__send__(self, *args)}
  end
end

>> [[1,2,3], [4,5,6], [7,8,9]].map(&:reverse)
=> [[3, 2, 1], [6, 5, 4], [9, 8, 7]]
>> (1..10).inject(&:+)
=> 55
>> {0=>"zero",1=>"one",2=>"two",3=>"three"}.sort_by(&:first).map(&:last)
=> ["zero", "one", "two", "three"]

However, I wonder whether below is what we want.

>> {1=>2,3=>4}.map(&:reverse)
=> [[2, 1], [4, 3]]


Thanks,
--
Nobuhiro IMAI