Make custom enumerable "flattenable"
Simply just alias to_a
to to_ary
class A
include Enumerable
def each
yield "a"
yield "b"
end
end
Without an alias, enumerables are not exploded properly…
[A.new, A.new].flatten => [#<A:0x00007fbddf1b5d88>, #<A:0x00007fbddf1b5d60>]
class A
def to_ary
to_a
end
end
…but with to_ary
provided, they are :D
[A.new, A.new].flatten => ["a", "b", "a", "b"]