Skip to content

Commit cba74fe

Browse files
committed
Fixes StrDistance, refs #2683
1 parent c9c2813 commit cba74fe

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

doc/Type/StrDistance.pod6

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
55
=SUBTITLE Contains the result of a string transformation.
66
7-
C<StrDistance> objects are used to represent the return of the L<string transformation|/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS> operator.
7+
C<StrDistance> objects are used to represent the return of the
8+
L<string transformation|/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS> operator.
89
910
say (($ = "fold") ~~ tr/old/new/).^name; # OUTPUT: «StrDistance␤»
1011
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+
A C<StrDistance> object will stringify to the resulting string after the
13+
transformation, and will numify to the distance between the two strings.
1214
1315
=begin code
1416
my $str = "fold";
@@ -19,20 +21,37 @@ say +$str-dist; # OUTPUT: «3␤» │
1921
2022
=head1 Methods
2123
22-
=head2 before
24+
=head2 method before
2325
24-
Property that returns the string before the transformation:
26+
This is actually a class attribute, and called as a method returns the string
27+
before the transformation:
2528
2629
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
2730
say $str-dist.before; #OUTPUT: «fold␤»
2831
29-
=head2 after
32+
=head2 method after
3033
31-
Returns the string after the transformation
34+
Also a class attribute, returns the string after the transformation
3235
3336
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
3437
say $str-dist.after; #OUTPUT: «fnew␤»
3538
39+
=head2 method Bool
40+
41+
Returns C<True> if before is different from C<After>.
42+
43+
=head2 method Numeric
44+
45+
Returns the distance as a number.
46+
47+
=head2 method Int
48+
49+
Defined as:
50+
51+
multi method Int(StrDistance:D:)
52+
53+
Returns the distance between the string before and after the transformation.
54+
3655
=end pod
3756

3857
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)