Skip to content

Commit

Permalink
Eliminates uneeded asides in the explanation of contains.
Browse files Browse the repository at this point in the history
This, please, closes #2303.

Also some reflow and adds some examples to the basic Cool version of `contains`.
  • Loading branch information
JJ committed Sep 12, 2018
1 parent d9a3ec2 commit df4f027
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
16 changes: 9 additions & 7 deletions doc/Language/operators.pod6
Expand Up @@ -2071,24 +2071,26 @@ this example, only the first element is printed:
say $_ if /A/ ff /B/; # OUTPUT: «AB␤»
}
If you only want to test against a start condition and have no stop condition,
C<*> can be used as the "stop" condition.
If you only want to test against a start condition and have no stop
condition, C<*> can be used as such.
for <A B C D E> {
say $_ if /C/ ff *; # OUTPUT: «C␤D␤E␤»
}
For the sed-like version, which does I<not> try C<$_> on the stop condition
after succeeding on the start condition, see L<C<fff>>.
For the sed-like version, which does I<not> try C<$_> on the stop
condition after succeeding on the start condition, see L<C<fff>>.
This operator cannot be overloaded, as it's handled specially by the compiler.
This operator cannot be overloaded, as it's handled specially by the
compiler.
=head2 infix C«^ff»
sub infix:<^ff>(Mu $a, Mu $b)
Works like L<C<ff>>, except it does not return C<True> for items matching the
start condition (including items also matching the stop condition).
Works like L<C<ff>>, except it does not return C<True> for items
matching the start condition (including items also matching the stop
condition).
A comparison:
Expand Down
20 changes: 17 additions & 3 deletions doc/Type/Cool.pod6
Expand Up @@ -1205,9 +1205,23 @@ Defined as:
method contains(Cool:D: |c)
Coerces the invocant L<C<Str>|/type/Str>, and call
L<C<Str.contains>|/type/Str#routine_contains> on it. Please refer to it
for arguments and general syntax.
Coerces the invocant L<C<Str>|/type/Str>, and calls
L<C<Str.contains>|/type/Str#routine_contains> on it. Please refer to
that version of the method for arguments and general syntax.
say 123.contains("2")# OUTPUT: «True␤»
Since L<Int> is a subclass of C<Cool>, C<123> is coerced to a C<Str> and
then C<contains> is called on it.
say (1,1, * + * … * > 250).contains(233)# OUTPUT: «True␤»
L<Seq>s are also subclasses of C<Cool>, and they are stringified to a
comma-separated form. In this case we are also using an C<Int>, which is
going to be stringified also; C<"233"> is included in that sequence, so
it returns C<True>. Please note that this sequence is not lazy; the
stringification of lazy sequences does not include each and every one of
their components for obvious reasons.
=head2 routine index
Expand Down

0 comments on commit df4f027

Please sign in to comment.