class PatternMatching::PatternMatch

Encapsulates pattern matching behaviors such as deep-matching of collection types as well as wildcard values such as `Any`.

Attributes

pattern[R]
value[R]

Public Class Methods

new(*pattern) click to toggle source
# File lib/pattern_matching/pattern_match.rb, line 10
def initialize(*pattern)
  @pattern = pattern
end

Public Instance Methods

===(*other) click to toggle source

As both self.pattern and other are slurped, they are guaranteed to begin as Arrays (i.e. they are enumerable). Thus all matches begin by checking a match as if the values are enumerable.

# File lib/pattern_matching/pattern_match.rb, line 18
def ===(*other)
  match_enumerable(pattern, other)
end