2007/12/3, Ryan Davis <ryand-ruby / zenspider.com>: > > With that not being recursive, how do you deal with sub-sub-arrays? > Hrm... it seems to work. A feature in splat? I'll have to look into > that. But: > > >> [:a, [:b, [:c], :d], :e].flatten2 > => [:e, :b, :c, :d, :a] > > Here the corrected version class Array def flatten2 res = [] x = self.dup while !x.empty? a = x.pop if a.is_a?(Array) a.each{|i| x << i} else res << a end end res.reverse end end