This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/misc/perl6advent-2010/articles/smartmatching.pod b/misc/perl6advent-2010/articles/smartmatching.pod | |
index cda1b95..b3f8afd 100644 | |
--- a/misc/perl6advent-2010/articles/smartmatching.pod | |
+++ b/misc/perl6advent-2010/articles/smartmatching.pod | |
@@ -41,11 +41,15 @@ C<m/.../> and C<.method_call>. | |
Here is what the smart match operator does with some matchers on the | |
right-hand side: | |
- matcher operation | |
- -------------------------- | |
- type object type check | |
- Numeric numeric equality | |
- Str string equality | |
- Regex $_ matches regex? | |
- Range $_ is inside the range | |
- Code closure is called with $_ as argument | |
+ # is it of type Str? | |
+ $foo ~~ Str | |
+ # is it equal to 6? | |
+ $foo ~~ 6 | |
+ # or is it "bar"? | |
+ $foo ~~ "bar" | |
+ # does it match some pattern? | |
+ $foo ~~ / \w+ '-' \d+ / # TODO: notice how that's the only way now, no =~ in Perl6 | |
+ # Is it between 15 and 25? | |
+ $foo ~~ (15..25) | |
+ # call a closure | |
+ $foo ~~ -> $x { say 'ok' if 5 < $x < 25 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment