Skip to content

Commit 40e5a15

Browse files
committed
Adds an example
And clarifies what happens if the second argument is not present. Addresses #2303. Not closing it until everyone is happy.
1 parent 77e4113 commit 40e5a15

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

doc/Type/Cool.pod6

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,19 +1203,25 @@ L<Regex|/type/Regex> as a list of strings.
12031203
12041204
multi method contains(Cool:D: Str(Cool) $needle, Cool $start? --> Bool:D)
12051205
1206-
Coerces the invocant and first argument to L<Str|/type/Str>, and searches for
1207-
C<$needle> in the string starting from C<$start> characters into the string. Returns C<True> if C<$needle>
1208-
is found.
1206+
Coerces the invocant and first argument to L<C<Str>|/type/Str>, and
1207+
searches for C<$needle> in the string starting from C<$start> characters
1208+
into the string. Returns C<True> if C<$needle> is found. C<$start> is an
1209+
optional parameter, and if it's not present, C<contains> will search
1210+
from the beginning of the string.
12091211
12101212
say "Hello, World".contains('Hello'); # OUTPUT: «True␤»
12111213
say "Hello, World".contains('hello'); # OUTPUT: «False␤»
1214+
say "Hello, World".contains('Hello', 1); # OUTPUT: «False␤»
12121215
say "Hello, World".contains(','); # OUTPUT: «True␤»
12131216
say "Hello, World".contains(',', 3); # OUTPUT: «True␤»
12141217
say "Hello, World".contains(',', 10); # OUTPUT: «False␤»
12151218
1216-
Note that because of how a L<List|/type/List> or L<Array|/type/Array> is
1217-
L<coerced|/type/List#method_Str> into a L<Str|/type/Str>, the results may
1218-
sometimes be surprising. See L<traps|/language/traps#Lists_become_strings,_so_beware_.contains()>.
1219+
In the third case, the C<'Hello'> string is not found since we have
1220+
started looking at the second position in it (index 1). Note that
1221+
because of how a L<List|/type/List> or L<Array|/type/Array> is
1222+
L<coerced|/type/List#method_Str> into a L<Str|/type/Str>, the results
1223+
may sometimes be surprising. See
1224+
L<traps|/language/traps#Lists_become_strings,_so_beware_.contains()>.
12191225
12201226
=head2 routine index
12211227
@@ -1411,14 +1417,15 @@ Returns a C<Complex> with the coordinates corresponding to the angle in
14111417
radians and magnitude corresponding to the object value or C<$mag> in
14121418
the case it's being used as a C<sub>
14131419
1414-
say 1.unpolar(⅓*pi);# OUTPUT: «0.5000000000000001+0.8660254037844386i␤»
1420+
say 1.unpolar(⅓*pi);
1421+
# OUTPUT: «0.5000000000000001+0.8660254037844386i␤»
14151422
14161423
=begin comment
14171424
14181425
14191426
14201427
TODO:
1421-
unpolar, fmt, substr-rw, trans,
1428+
fmt, substr-rw, trans,
14221429
match, subst, sprintf, printf, samecase
14231430
14241431
=end comment

0 commit comments

Comments
 (0)