File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ and Undefined objects. Plain type objects are undefined while instansiated objec
60
60
sub parse-int(Str $s --> Int) { ... }
61
61
62
62
given parse-int($string) {
63
- when Int:D { * }
63
+ when Int:D { $_ }
64
64
when Int:U { 0 }
65
65
}
66
66
@@ -79,8 +79,8 @@ that specifically test for definedness.
79
79
80
80
# One way to do it
81
81
given parse-int($string) {
82
- when * ~~ Int:D { * }
83
- when * ~~ Int:U { 0 }
82
+ when Int:D { $_ }
83
+ when Int:U { 0 }
84
84
}
85
85
86
86
# Another way to do it
@@ -89,7 +89,10 @@ that specifically test for definedness.
89
89
90
90
91
91
# A better way
92
- with parse-int($string) { * } else { 0 }
92
+ with parse-int($string) { $_ } else { 0 }
93
+
94
+ # With the defined-or operator
95
+ parse-int($string) // 0
93
96
94
97
The `with` operator that you see above is like `if`, except it explicitly tests for definedness and then
95
98
passes the result to the following block. Similarly, `without` tests that the object is undefined and also
You can’t perform that action at this time.
0 commit comments