Method: Array#flatten
- Defined in:
- lib/jinx/helpers/array.rb
#flatten ⇒ Object
Recursively flattens this array, including any collection item that implements the to_a method.
84 85 86 87 88 89 90 |
# File 'lib/jinx/helpers/array.rb', line 84 def flatten # if any item is a Set or Java Collection, then convert those into arrays before recursively flattening the list if any? { |item| Set === item or Java::JavaUtil::Collection === item } then return map { |item| (Set === item or Java::JavaUtil::Collection === item) ? item.to_a : item }.flatten end base__flatten end |