class Array

TODO: Figure out how to put this into a refinement.

Public Instance Methods

destructure(num_elems) click to toggle source

Destructuring for the array class. If the array is being matched against two patterns the destructuring of the array will be the first element and then an array containing the rest of the values. If there are three patterns the destructuring of the array will be the first and second elements, and then an array containing the remainder of the values.

@param [Integer] num_elems Number of sub-pattern elements

@return [Array<Object>]

# File lib/filigree/match.rb, line 636
def destructure(num_elems)
        [*self.first(num_elems - 1), self[(num_elems - 1)..-1]]
end