Symbol#to_proc: fix with arrays of arrays

Previously, with nested arrays, the Symbol#to_proc would iterate over
the first item in the nested array instead of the array itself, e.g.:

[[1,2], [3,4]].map(&:first) #=>
	NoMethodError: undefined method `first' for 1:Fixnum
This commit is contained in:
Misty De Meo 2014-03-08 10:37:58 -08:00
parent 9850e84f3b
commit 53a2558473

View File

@ -1,5 +1,5 @@
class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
proc { |*args| args.shift.send(self, *args) }
end unless method_defined?(:to_proc)
end