File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,12 @@ You can purposefully assign C<Nil> as a default value:
59
59
60
60
= begin code
61
61
my %h is default(Nil) = a => Nil;
62
- dd %h; # OUTPUT: «Hash %h = {:a(Nil)}»
62
+ say %h; # OUTPUT: «Hash %h = {:a(Nil)}»
63
63
= end code
64
64
65
65
Or bind a value to C < Nil > if that is the result you want:
66
66
67
- = begin code
67
+ = begin code :preamble<my @a = 1,2,3,4;>
68
68
@a[3] := Nil;
69
69
say @a; # OUTPUT: «[4 8 (Any) Nil]»
70
70
= end code
Original file line number Diff line number Diff line change @@ -76,11 +76,11 @@ for @examples -> $eg {
76
76
77
77
# #1355 - don't like .WHAT in examples
78
78
if ! $ eg <ok-test >. contains (' WHAT' ) && $ eg <contents >. contains (' .WHAT' ) {
79
- flunk " $ eg <file> chunk $ eg <count> " ~ ' uses .WHAT: try .^name instead' ;
79
+ flunk " $ eg <file> chunk starting with « " ~ starts-with ( $ eg <contents >) ~ ' » uses .WHAT: try .^name instead' ;
80
80
next ;
81
81
}
82
82
if ! $ eg <ok-test >. contains (' dd' ) && $ eg <contents > ~~ / << 'dd' >> / {
83
- flunk " $ eg <file> chunk $ eg <count> " ~ ' uses dd: try say instead' ;
83
+ flunk " $ eg <file> chunk starting with « " ~ starts-with ( $ eg <contents >) ~ ' » uses dd: try say instead' ;
84
84
next ;
85
85
}
86
86
@@ -104,7 +104,7 @@ for @examples -> $eg {
104
104
$ code ~ = " \{ }\n " if $ eg <method > eq " True" ;
105
105
$ code ~ = " \n }}" ;
106
106
107
- my $ msg = " $ eg <file> chunk $ eg <count> starts with “" ~ ($ eg <contents >. lines )[ 0 ] . substr ( 0 , 10 ) . trim ~ " ” compiles" ;
107
+ my $ msg = " $ eg <file> chunk $ eg <count> starts with “" ~ starts-with ($ eg <contents >) ~ " ” compiles" ;
108
108
109
109
my $ status ;
110
110
{
@@ -122,3 +122,7 @@ for @examples -> $eg {
122
122
pass $ msg ;
123
123
}
124
124
}
125
+
126
+ sub starts-with ( Str $ chunk ) {
127
+ ($ chunk . lines )[0 ]. substr (0 ,10 ). trim
128
+ }
You can’t perform that action at this time.
0 commit comments