@@ -1203,19 +1203,25 @@ L<Regex|/type/Regex> as a list of strings.
1203
1203
1204
1204
multi method contains(Cool:D: Str(Cool) $needle, Cool $start? --> Bool:D)
1205
1205
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.
1209
1211
1210
1212
say "Hello, World".contains('Hello'); # OUTPUT: «True»
1211
1213
say "Hello, World".contains('hello'); # OUTPUT: «False»
1214
+ say "Hello, World".contains('Hello', 1); # OUTPUT: «False»
1212
1215
say "Hello, World".contains(','); # OUTPUT: «True»
1213
1216
say "Hello, World".contains(',', 3); # OUTPUT: «True»
1214
1217
say "Hello, World".contains(',', 10); # OUTPUT: «False»
1215
1218
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() > .
1219
1225
1220
1226
= head2 routine index
1221
1227
@@ -1411,14 +1417,15 @@ Returns a C<Complex> with the coordinates corresponding to the angle in
1411
1417
radians and magnitude corresponding to the object value or C < $mag > in
1412
1418
the case it's being used as a C < sub >
1413
1419
1414
- say 1.unpolar(⅓*pi);# OUTPUT: «0.5000000000000001+0.8660254037844386i»
1420
+ say 1.unpolar(⅓*pi);
1421
+ # OUTPUT: «0.5000000000000001+0.8660254037844386i»
1415
1422
1416
1423
= begin comment
1417
1424
1418
1425
1419
1426
1420
1427
TODO:
1421
- unpolar, fmt, substr-rw, trans,
1428
+ fmt, substr-rw, trans,
1422
1429
match, subst, sprintf, printf, samecase
1423
1430
1424
1431
= end comment
0 commit comments