MatchResult
public enum MatchResult<T>
Whenever a match operation is performed, the result is going to be a MatchResult instance.
-
The input could not be matched
Declaration
Swift
case noMatch -
The input can match, if it were continued. (It’s the prefix of the matching expression)
Declaration
Swift
case possibleMatch -
The input matches the expression. It provides information about the
lengthof the matched input, theoutputafter the evaluation, and thevariablesthat were processed during the process.Declaration
Swift
case exactMatch(length: Int, output: T, variables: [String : Any])Parameters
lengthThe length of the match in the input string
outputThe interpreted content
variablesThe key-value pairs of the found
Variableinstances along the way -
In case the matching sequence only consists of one variable, the result is going to be anyMatch
Declaration
Swift
case anyMatch(exhaustive: Bool)Parameters
exhaustiveWhether the matching should be exaustive or just return the shortest matching result
-
Shorter syntax for pattern matching
MatchResult.exactMatchDeclaration
Swift
func isMatch() -> BoolReturn Value
Whether the case of the current instance is
exactMatch -
Shorter syntax for pattern matching
MatchResult.anyMatchDeclaration
Swift
func isAnyMatch(exhaustive: Bool = false) -> BoolParameters
exhaustiveIf the result is
anyMatch, this one filter the content by its exhaustive parameter - if provided. UsesfalseotherwiseReturn Value
Whether the case of the current instance is
anyMatch -
Shorter syntax for pattern matching
MatchResult.noMatchDeclaration
Swift
func isNoMatch() -> BoolReturn Value
Whether the case of the current instance is
noMatch -
Shorter syntax for pattern matching
MatchResult.anypossibleMatchDeclaration
Swift
func isPossibleMatch() -> BoolReturn Value
Whether the case of the current instance is
possibleMatch
-
MatchResultwith Equatable objects are also EquatableDeclaration
Swift
static func == (lhs: MatchResult<T>, rhs: MatchResult<T>) -> BoolParameters
lhsLeft hand side
rhsRight hand side
Return Value
Whether the
MatchResulthave the same values, including the contents of their associated objects
View on GitHub
Install in Dash
MatchResult Enumeration Reference