Actions
Bug #5759
closedflatten calls to_ary on everything
Description
I often ensure that I have an array by doing:
def foo=(x)
@foo = [x].flatten
end
But this has turned into a problem as of late, as it seems #flatten is calling #to_ary on every element in the array, and apparently catching the error raised if #to_ary isn't defined for that object. But that causes potential issues with objects that use #method_missing. I think #flatten should use respond_to?(:to_ary)
to make sure an object can handle it before actually calling it.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0