Raku's pattern matching system is complex but it is modular and each component is composable with others in interesting and thoughtful ways.
# Smartmatch Operator
- https://docs.raku.org/language/operators#infix_~~
> The smartmatch operator aliases the left-hand side to `$_`, then evaluates the right-hand side and calls `.ACCEPTS($_)` on it
>
> Here is a partial list of some of the built-in smartmatching functionality.
|Right-hand side|Comparison semantics|
|---|---|
|Mu:U|type check|
|Str|string equality|
|Numeric|numeric equality|
|Regex|regex match|
|Callable|Boolean result of invocation|
|Set/Bag|equal element values|
|Any:D|object identity|
Above is a subset of [[#Accepts]] functionality for quick reference.
## Substitution
The `~~` operator can also be used together with other features, like the [in-place substitution](https://docs.raku.org/language/operators#s///_in-place_substitution) operator `s///` (`s/rule/replacement/options`):
```perl
# raku
my $str = 'old string';
$str ~~ s/o .+ d/new/;
say $str; # OUTPUT: «new string»
```
# Given
Really just a shiny switch statement:
- https://docs.raku.org/language/control#given
# Accepts
- https://docs.raku.org/routine/ACCEPTS
Accepts is [[Raku]]'s [[Constraints]] system.