Class: Array

Inherits:
Object show all
Extended by:
Filigree::Destructurable
Defined in:
lib/filigree/match.rb

Overview

Standard Library Deconstructors #

Instance Method Summary collapse

Methods included from Filigree::Destructurable

call

Instance Method Details

#destructure(num_elems) ⇒ Array<Object>

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.

Parameters:

  • num_elems (Fixnum)

    Number of sub-pattern elements

Returns:



637
638
639
# File 'lib/filigree/match.rb', line 637

def destructure(num_elems)
	[*self.first(num_elems - 1), self[(num_elems - 1)..-1]]
end