txt: ## strdistance.md
  class StrDistance
  
  Contains the result of a string transformation.
  
  `StrDistance` objects are used to represent the return of the [string transformation](/language/operators#tr///_in-place_transliteration) operator.
  
  ```raku
  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.
  
  ```raku
  my $str = "fold";
  my $str-dist = ($str ~~ tr/old/new/);
  say ~$str-dist;  # OUTPUT: «fnew␤»
  say +$str-dist;  # OUTPUT: «3␤»
  
  ```
  
  # [Methods](#class_StrDistance "go to top of document")[§](#Methods "direct link")
  
  ## [method before](#class_StrDistance "go to top of document")[§](#method_before "direct link")
  
  This is actually a class attribute, and called as a method returns the string before the transformation:
  
  ```raku
  say $str-dist.before; # OUTPUT: «fold␤»
  
  ```
  
  ## [method after](#class_StrDistance "go to top of document")[§](#method_after "direct link")
  
  Also a class attribute, returns the string after the transformation:
  
  ```raku
  say $str-dist.after;  # OUTPUT: «fnew␤»
  
  ```
  
  ## [method Bool](#class_StrDistance "go to top of document")[§](#method_Bool "direct link")
  
  Returns `True` if `before` is different from `after`.
  
  ## [method Numeric](#class_StrDistance "go to top of document")[§](#method_Numeric "direct link")
  
  Returns the distance as a number.
  
  ## [method Int](#class_StrDistance "go to top of document")[§](#method_Int "direct link")
  
  ```raku
  multi method Int(StrDistance:D:)
  ```
  
  Returns the distance between the string before and after the transformation.
  
  ## [method Str](#class_StrDistance "go to top of document")[§](#method_Str "direct link")
  
  ```raku
  multi method Str(StrDistance:D: --> Str)
  ```
  
  Returns an `after` string value.
  
  ```raku
  my $str-dist = ($str ~~ tr/old/new/);
  say $str-dist.Str; # OUTPUT: «fnew␤»
  say ~$str-dist;    # OUTPUT: «fnew␤»
  
  ```
  
  # [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")
  
  Type relations for `StrDistance`
  
  
  
  raku-type-graph
  
  
  
  StrDistance
  StrDistance
  
  
  Cool
  Cool
  
  
  StrDistance->Cool
  
  
  
  Mu
  Mu
  
  
  Any
  Any
  
  
  Any->Mu
  
  
  
  Cool->Any
  
  [Expand chart above](/assets/typegraphs/StrDistance.svg)
  