Skip to content

Commit df4f027

Browse files
committed
Eliminates uneeded asides in the explanation of contains.
This, please, closes #2303. Also some reflow and adds some examples to the basic Cool version of `contains`.
1 parent d9a3ec2 commit df4f027

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

doc/Language/operators.pod6

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,24 +2071,26 @@ this example, only the first element is printed:
20712071
say $_ if /A/ ff /B/; # OUTPUT: «AB␤»
20722072
}
20732073
2074-
If you only want to test against a start condition and have no stop condition,
2075-
C<*> can be used as the "stop" condition.
2074+
If you only want to test against a start condition and have no stop
2075+
condition, C<*> can be used as such.
20762076
20772077
for <A B C D E> {
20782078
say $_ if /C/ ff *; # OUTPUT: «C␤D␤E␤»
20792079
}
20802080
2081-
For the sed-like version, which does I<not> try C<$_> on the stop condition
2082-
after succeeding on the start condition, see L<C<fff>>.
2081+
For the sed-like version, which does I<not> try C<$_> on the stop
2082+
condition after succeeding on the start condition, see L<C<fff>>.
20832083
2084-
This operator cannot be overloaded, as it's handled specially by the compiler.
2084+
This operator cannot be overloaded, as it's handled specially by the
2085+
compiler.
20852086
20862087
=head2 infix C«^ff»
20872088
20882089
sub infix:<^ff>(Mu $a, Mu $b)
20892090
2090-
Works like L<C<ff>>, except it does not return C<True> for items matching the
2091-
start condition (including items also matching the stop condition).
2091+
Works like L<C<ff>>, except it does not return C<True> for items
2092+
matching the start condition (including items also matching the stop
2093+
condition).
20922094
20932095
A comparison:
20942096

doc/Type/Cool.pod6

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,23 @@ Defined as:
12051205
12061206
method contains(Cool:D: |c)
12071207
1208-
Coerces the invocant L<C<Str>|/type/Str>, and call
1209-
L<C<Str.contains>|/type/Str#routine_contains> on it. Please refer to it
1210-
for arguments and general syntax.
1208+
Coerces the invocant L<C<Str>|/type/Str>, and calls
1209+
L<C<Str.contains>|/type/Str#routine_contains> on it. Please refer to
1210+
that version of the method for arguments and general syntax.
1211+
1212+
say 123.contains("2")# OUTPUT: «True␤»
1213+
1214+
Since L<Int> is a subclass of C<Cool>, C<123> is coerced to a C<Str> and
1215+
then C<contains> is called on it.
1216+
1217+
say (1,1, * + * … * > 250).contains(233)# OUTPUT: «True␤»
1218+
1219+
L<Seq>s are also subclasses of C<Cool>, and they are stringified to a
1220+
comma-separated form. In this case we are also using an C<Int>, which is
1221+
going to be stringified also; C<"233"> is included in that sequence, so
1222+
it returns C<True>. Please note that this sequence is not lazy; the
1223+
stringification of lazy sequences does not include each and every one of
1224+
their components for obvious reasons.
12111225
12121226
=head2 routine index
12131227

0 commit comments

Comments
 (0)