class StrDistance

Contains the result of a string transformation.

StrDistance objects are used to represent the return of the string transformation operator.

say (($ = "fold"~~ tr/old/new/).^name;# OUTPUT: «StrDistance␤» 

A StrDistance object will stringify to the resulting string after the transformation, and will numify to the distance between the two strings.

my $str = "fold";
my $str-dist = ($str ~~ tr/old/new/);
say ~$str-dist;  # OUTPUT: «fnew␤» 
say +$str-dist;  # OUTPUT: «3␤»                                       │ 



Property that returns the string before the transformation:

say $str-dist.before#OUTPUT: «fold␤» 


Returns the string after the transformation

say $str-dist.after#OUTPUT: «fnew␤»