Actions
Bug #10684
closedBlock arity changes through Enumerable methods
Description
Blocks traveling through methods in Enumerable have their arity changed before reaching #each. Example:
class MyEnumerator
include Enumerable
def initialize(ary)
@ary = ary
end
def each(&block)
puts block.arity
@ary.each(&block)
end
end
my_enum = MyEnumerator.new([1,2,3])
my_enum.each{|x| x} # outputs 1
my_enum.detect{|x| x} # outputs -1
This is surprising behavior. I would expect the output to be 1 in both cases since the blocks appear identical to me as a programmer.
Actions
Like0
Like0Like0Like0