Actions
Bug #20003
closedArray#rassoc does not preform implicit conversion
Description
There is a difference between behaviour of Array#assoc and Array#rassoc. The first one performs implicit conversion (calls #to_ary) while the former does not.
class ArrayConvertible
def initialize(*values)
@values = values;
end
def to_ary
@values
end
end
s1 = [1, 2]
s2 = ArrayConvertible.new(2, 3)
a = [s1, s2]
The a.assoc(2)
call returns [2, 3]
as expected. However, a.rassoc(3)
returns nil
Expected behaviour: a.rassoc(3)
returns [2, 3]
in such cases.
Actions
Like0
Like0Like0Like0