Skip to content

Commit 40921d4

Browse files
committed
Changing the definition of words
And adding another example. After @lizmat latest addition, the definition was no longer in sync with the source. This refs #2340
1 parent 7e83c32 commit 40921d4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

doc/Type/Str.pod6

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ Examples:
537537
538538
=head2 routine words
539539
540-
multi sub words(Str:D $input, $limit = Inf --> Seq)
541-
multi method words(Str:D $input: $limit = Inf --> Seq)
540+
multi method words(Str:D: $limit)
541+
multi method words(Str:D:)
542542
543543
Returns a list of non-whitespace bits, i.e. the same as a call to
544544
C<$input.comb( / \S+ /, $limit )> would.
@@ -550,6 +550,14 @@ Examples:
550550
say "foo:bar".words.perl; # OUTPUT: «("foo:bar",).Seq␤»
551551
say "foo:bar\tbaz".words.perl; # OUTPUT: «("foo:bar", "baz").Seq␤»
552552
553+
As can be seen by the definition, it can also be used as a subroutine, turning
554+
the first argument into the invocant. C<$limit> is optional, but if it is
555+
provided (and not equal to C<Inf>), it will return only the first C<$limit>
556+
words.
557+
558+
say words("I will be very brief here",2); # OUTPUT: «(I will)␤»
559+
560+
553561
=head2 routine flip
554562
555563
multi sub flip(Str:D --> Str:D)

0 commit comments

Comments
 (0)