Either.match

Tuple!(bool, Pattern[], Pattern[]) match(Pattern[] left, Pattern[] collected = null)

Attempts to match one of the alternative patterns.

Tries each alternative and returns the one that matches with the fewest remaining arguments. As an optimization, if an alternative matches perfectly (i.e. with no remaining arguments), the search terminates early and that result is returned immediately. This preserves existing semantics (the first perfect match wins) while avoiding unnecessary work for large alternative sets.

Parameters

leftThe remaining arguments to match.
collectedPreviously collected/matched patterns.

Returns

A tuple of (matched, remaining_args, collected_patterns).