Skip to content

Commit 6288b87

Browse files
committed
Tidy Range, address sink context warning.
1 parent 3d00917 commit 6288b87

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

doc/Type/Range.pod6

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,41 +88,42 @@ As an example:
8888
8989
my $p = Range.new( 3, 5 );
9090
my $r = Range.new( 1, 10 );
91-
$p.ACCEPTS( $r ); # False
92-
$r.ACCEPTS( $p ); # True
93-
$r ~~ $p; # False (same as $p.ACCEPTS( $r )
94-
$p ~~ $r; # True (same as $r.ACCEPTS( $p )
91+
92+
say $p.ACCEPTS( $r ); # OUTPUT: «False␤»
93+
say $r.ACCEPTS( $p ); # OUTPUT: «True␤»
94+
say $r ~~ $p; # OUTPUT: «False␤» (same as $p.ACCEPTS( $r )
95+
say $p ~~ $r; # OUTPUT: «True␤» (same as $r.ACCEPTS( $p )
9596
9697
Of course, an infinite C<Range> always contains another C<Range>, therefore:
9798
98-
1..10 ~~ -∞..∞; # True
99-
1..10 ~~ -∞^..^∞; # True
99+
say 1..10 ~~ -∞..∞; # OUTPUT: «True␤»
100+
say 1..10 ~~ -∞^..^∞; # OUTPUT: «True␤»
100101
101102
Similarly, a C<Range> with open boundaries often includes other ranges:
102103
103-
1..2 ~~ *..10; # True
104-
2..5 ~~ 1..*; # True
104+
say 1..2 ~~ *..10; # OUTPUT: «True␤»
105+
say 2..5 ~~ 1..*; # OUTPUT: «True␤»
105106
106107
107108
It is also possible to use non-numeric ranges, for instance string based
108109
ones:
109110
110-
'a'..'j' ~~ 'b'..'c'; # False
111-
'b'..'c' ~~ 'a'..'j'; # True
112-
'perl' ~~ -∞^..^∞; # True
113-
'perl' ~~ -∞..∞; # True
114-
'perl' ~~ 1..*; # True
111+
say 'a'..'j' ~~ 'b'..'c'; # OUTPUT: «False␤»
112+
say 'b'..'c' ~~ 'a'..'j'; # OUTPUT: «True␤»
113+
say 'perl' ~~ -∞^..^∞; # OUTPUT: «True␤»
114+
say 'perl' ~~ -∞..∞; # OUTPUT: «True␤»
115+
say 'perl' ~~ 1..*; # OUTPUT: «True␤»
115116
116117
117118
When smart-matching a C<Range> of integers with a L<Cool> (string)
118119
the C<ACCEPTS> methods exploits the L<before|/routine/before>
119120
and L<after|/routine/after> operators in order to check that
120121
the C<Cool> value is overlapping the range:
121122
122-
1.10 ~~ '5'; # False
123-
'5' before 1; # False
124-
'5' after 10; # True
125-
'5' ~~ *..10; # False
123+
say 1.10 ~~ '5'; # OUTPUT: «False␤»
124+
say '5' before 1; # OUTPUT: «False␤»
125+
say '5' after 10; # OUTPUT: «True␤»
126+
say '5' ~~ *..10; # OUTPUT: «False␤»
126127
127128
In the above example, since the C<'5'> string is I<after> the C<10> integer value,
128129
the C<Range> does not overlap with the specified value.

0 commit comments

Comments
 (0)