Skip to content

Commit 3757cf8

Browse files
committed
Add Supply.split #3187
1 parent 30dc5dd commit 3757cf8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/Type/Supply.pod6

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,22 @@ according to named parameter C<:end>.
444444
# then the $first-prime supply reaches its end
445445
$first-prime.tap: &say;
446446
447+
=head2 method split
448+
449+
multi method split(Supply:D: \delimiter)
450+
multi method split(Supply:D: \delimiter, \limit)
451+
452+
This method creates a supply of the values returned by the C<Str.split>
453+
method called on the string collected from the invocant.
454+
See L«C<Str.split>|/type/Str#routine_split» for details on the
455+
C<\delimiter> argument as well as available extra named parameters.
456+
The created supply can be limited with the C<\limit> argument, see
457+
L«C<.head>|#method head».
458+
459+
my $words = Supply.from-list(<Hello World From Raku!>);
460+
my $s = $words.split(/ <?upper> /, 2, :skip-empty);
461+
$s.tap(&say); # OUTPUT: «Hello␤World␤»
462+
447463
=head2 method rotor
448464
449465
method rotor(Supply:D: @cycle --> Supply:D)

0 commit comments

Comments
 (0)