module Alda::Sequence::RefineFlatten

Using this module can fix a bug of Array#flatten.

def (a = Object.new).method_missing(...)
  Object.new
end
[a].flatten rescue $! # => #<TypeError:...>
using Alda::Sequence::RefineFlatten
[a].flatten # => [#<Object:...>]

Public Instance Methods

flatten() click to toggle source
# File lib/alda-rb/event.rb, line 832
def flatten
  each_with_object [] do |element, result|
    if element.is_a? Array
      result.push *element.flatten
    else
      result.push element
    end
  end
end