txt: ## trim.md
  trim
  
  Combined from primary sources listed below.
  
  # [In Allomorph](#___top "go to top of document")[§](#(Allomorph)_method_trim "direct link")
  
  See primary documentation
  [in context](/type/Allomorph#method_trim)
  for **method trim**.
  
  ```raku
  method trim(Allomorph:D:)
  ```
  
  Calls [`Str.trim`](/type/Str#method_trim) on the invocant's [`Str`](/type/Str) value.
  
  # [In Str](#___top "go to top of document")[§](#(Str)_method_trim "direct link")
  
  See primary documentation
  [in context](/type/Str#method_trim)
  for **method trim**.
  
  ```raku
  method trim(Str:D: --> Str)
  ```
  
  Remove leading and trailing whitespace. It can be used both as a method on strings and as a function. When used as a method it will return the trimmed string. In order to do in-place trimming, one needs to write `.=trim`
  
  ```raku
  my $line = '   hello world    ';
  say '<' ~ $line.trim ~ '>';        # OUTPUT: «<hello world>␤»
  say '<' ~ trim($line) ~ '>';       # OUTPUT: «<hello world>␤»
  $line.trim;
  say '<' ~ $line ~ '>';             # OUTPUT: «<   hello world    >␤»
  $line.=trim;
  say '<' ~ $line ~ '>';             # OUTPUT: «<hello world>␤»
  ```
  
  See also [trim-trailing](/routine/trim-trailing) and [trim-leading](/routine/trim-leading).
  
  # [In Cool](#___top "go to top of document")[§](#(Cool)_routine_trim "direct link")
  
  See primary documentation
  [in context](/type/Cool#routine_trim)
  for **routine trim**.
  
  ```raku
  sub trim(Str(Cool))
  method trim()
  ```
  
  Coerces the invocant (or in sub form, its argument) to [`Str`](/type/Str), and returns the string with both leading and trailing whitespace stripped.
  
  ```raku
  my $stripped = '  abc '.trim;
  say "<$stripped>";          # OUTPUT: «<abc>␤»
  ```
  