Skip to content

Commit

Permalink
Fixes StrDistance, refs #2683
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Mar 20, 2019
1 parent c9c2813 commit cba74fe
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions doc/Type/StrDistance.pod6
Expand Up @@ -4,11 +4,13 @@
=SUBTITLE Contains the result of a string transformation.
C<StrDistance> objects are used to represent the return of the L<string transformation|/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS> operator.
C<StrDistance> objects are used to represent the return of the
L<string transformation|/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS> operator.
say (($ = "fold") ~~ tr/old/new/).^name; # OUTPUT: «StrDistance␤»
A C<StrDistance> object will stringify to the resulting string after the transformation, and will numify to the distance between the two strings.
A C<StrDistance> object will stringify to the resulting string after the
transformation, and will numify to the distance between the two strings.
=begin code
my $str = "fold";
Expand All @@ -19,20 +21,37 @@ say +$str-dist; # OUTPUT: «3␤» │
=head1 Methods
=head2 before
=head2 method before
Property that returns the string before the transformation:
This is actually a class attribute, and called as a method returns the string
before the transformation:
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
say $str-dist.before; #OUTPUT: «fold␤»
=head2 after
=head2 method after
Returns the string after the transformation
Also a class attribute, returns the string after the transformation
=for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
say $str-dist.after; #OUTPUT: «fnew␤»
=head2 method Bool
Returns C<True> if before is different from C<After>.
=head2 method Numeric
Returns the distance as a number.
=head2 method Int
Defined as:
multi method Int(StrDistance:D:)
Returns the distance between the string before and after the transformation.
=end pod

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

0 comments on commit cba74fe

Please sign in to comment.