Skip to content

Commit b0e6792

Browse files
committed
Adds a Type page for StrDistance
Closes #691
1 parent 2b6644b commit b0e6792

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

doc/Type/StrDistance.pod6

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=begin pod
2+
3+
=TITLE class StrDistance
4+
5+
=SUBTITLE Contains the result of a string transformation.
6+
7+
C<StrDistance> objects are used to represent the return of the L<tr|https://docs.perl6.org/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS> operator.
8+
9+
say (($ = "fold") ~~ tr/old/new/).^name;# OUTPUT: «StrDistance␤»
10+
11+
A C<StrDistance> object will stringify to the resulting string after the transformation, and will numify to the distance between the two strings.
12+
13+
=begin code
14+
my $str = "fold";
15+
my $str-dist = ($str ~~ tr/old/new/);
16+
say ~$str-dist; # OUTPUT: «fnew␤»
17+
say +$str-dist; # OUTPUT: «3␤» │
18+
=end code
19+
20+
=head1 Methods
21+
22+
=head2 before
23+
24+
Property that returns the string before the transformation:
25+
26+
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
27+
say $str-dist.before; #OUTPUT: «fold␤»
28+
29+
=head2 after
30+
31+
Returns the string after the transformation
32+
33+
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
34+
say $str-dist.after; #OUTPUT: «fnew␤»
35+
36+
=end pod
37+
38+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

xt/words.pws

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ findmethod
381381
flatmap
382382
flipflop
383383
fmt
384+
fnew
384385
foreach
385386
formatter
386387
formline
@@ -850,6 +851,7 @@ plaintext
850851
pluggable
851852
png
852853
podtohtml
854+
polation
853855
polymod
854856
polymorphism
855857
portably
@@ -1371,4 +1373,3 @@ yyyy
13711373
zef
13721374
zoffixznet
13731375
zwj
1374-
polation

0 commit comments

Comments
 (0)