Method: Array#to_a_recursive
- Defined in:
- lib/quality_extensions/array/to_a_recursive.rb
#to_a_recursive ⇒ Object
A lot like array.flatten, except that it will also “flatten” ranges (by converting range to range.to_a) and any other objects that respond to to_a contained in the array in addition to arrays contained in the array. Compare with Array#expand_ranges
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quality_extensions/array/to_a_recursive.rb', line 12 def to_a_recursive map do |item| # Assume that all arrays contain only elements that do not respond to to_a_recursive or arrays. if item.respond_to? :to_a_recursive item.to_a_recursive else item.to_a end end end |