2018-09-16 15:09:52 -04:00
|
|
|
class FlattenArray
|
2018-09-21 09:19:16 -04:00
|
|
|
def self.flatten(array, result = [])
|
2018-09-16 15:09:52 -04:00
|
|
|
array.each do |a|
|
|
|
|
if a.is_a? Array
|
2018-09-21 09:19:16 -04:00
|
|
|
flatten(a, result)
|
2018-09-16 15:09:52 -04:00
|
|
|
else
|
|
|
|
result << a unless a.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|