Method: Array#recursively

Defined in:
lib/core/facets/array/recursively.rb

#recursively(*types, &block) ⇒ Object

Apply a method to array, and recursively apply that method to each sub-array or types.

arr = ["a", ["b", "c"]]
arr.recursively.map{ |v| v.to_sym }
#=> [:a, [:b, :c]]

By default the sub-types are passed thru uneffected. Passing a block to #recursively changes this.

arr = ["a", ["b", "c"]]
arr.recursively{ |a| a.reverse }.map{ |v| v.to_sym }
#=> [:a, [:c, :b]]

TODO: Return Enumerator if no yld block is given ?



21
22
23
# File 'lib/core/facets/array/recursively.rb', line 21

def recursively(*types, &block)
  Recursor.new(self, *types, &block)
end