txt: ## ratstr.md
  class RatStr
  
  Dual value rational number and string
  
  ```raku
  class RatStr is Allomorph is Rat {}
  ```
  
  `RatStr` is a dual value type, a subclass of both [`Allomorph`](/type/Allomorph), hence [`Str`](/type/Str), and [`Rat`](/type/Rat).
  
  See [`Allomorph`](/type/Allomorph) for further details.
  
  ```raku
  my $rat-str = <42.1>;
  say $rat-str.^name;       # OUTPUT: «RatStr␤»
  
  my Rat $rat = $rat-str;   # OK!
  my Str $str = $rat-str;   # OK!
  
  # ∈ operator cares about object identity
  say 42.1 ∈ <42.1  55  1>; # OUTPUT: «False␤»
  
  ```
  
  # [Methods](#class_RatStr "go to top of document")[§](#Methods "direct link")
  
  ## [method new](#class_RatStr "go to top of document")[§](#method_new "direct link")
  
  ```raku
  method new(Rat $i, Str $s)
  ```
  
  The constructor requires both the [`Rat`](/type/Rat) and the [`Str`](/type/Str) value, when constructing one directly the values can be whatever is required:
  
  ```raku
  my $f = RatStr.new(42.1, "forty two and a bit");
  say +$f; # OUTPUT: «42.1␤»
  say ~$f; # OUTPUT: «"forty two and a bit"␤»
  ```
  
  ## [method Capture](#class_RatStr "go to top of document")[§](#method_Capture "direct link")
  
  ```raku
  method Capture(RatStr:D: --> Capture:D)
  ```
  
  Equivalent to [`Mu.Capture`](/type/Mu#method_Capture).
  
  ## [method Numeric](#class_RatStr "go to top of document")[§](#method_Numeric "direct link")
  
  ```raku
  multi method Numeric(RatStr:D: --> Rat:D)
  multi method Numeric(RatStr:U: --> Rat:D)
  ```
  
  The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.
  
  ## [method Rat](#class_RatStr "go to top of document")[§](#method_Rat "direct link")
  
  ```raku
  method Rat
  ```
  
  Returns the [`Rat`](/type/Rat) value of the `RatStr`.
  
  ## [method Real](#class_RatStr "go to top of document")[§](#method_Real "direct link")
  
  ```raku
  multi method Real(Real:D: --> Rat:D)
  multi method Real(Real:U: --> Rat:D)
  ```
  
  The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.
  
  # [Operators](#class_RatStr "go to top of document")[§](#Operators "direct link")
  
  ## [infix `===`](#class_RatStr "go to top of document")[§](#infix_=== "direct link")
  
  ```raku
  multi infix:<===>(RatStr:D $a, RatStr:D $b)
  ```
  
  `RatStr` Value identity operator. Returns `True` if the [`Rat`](/type/Rat) values of `$a` and `$b` are [identical](/routine/===) and their [`Str`](/type/Str) values are also [identical](/routine/===). Returns `False` otherwise.
  
  # [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")
  
  Type relations for `RatStr`
  
  
  
  raku-type-graph
  
  
  
  RatStr
  RatStr
  
  
  Allomorph
  Allomorph
  
  
  RatStr->Allomorph
  
  
  
  Rat
  Rat
  
  
  RatStr->Rat
  
  
  
  Mu
  Mu
  
  
  Any
  Any
  
  
  Any->Mu
  
  
  
  Cool
  Cool
  
  
  Cool->Any
  
  
  
  Stringy
  Stringy
  
  
  Str
  Str
  
  
  Str->Cool
  
  
  
  Str->Stringy
  
  
  
  Allomorph->Str
  
  
  
  Numeric
  Numeric
  
  
  Real
  Real
  
  
  Real->Numeric
  
  
  
  Rational
  Rational
  
  
  Rational->Real
  
  
  
  Rat->Cool
  
  
  
  Rat->Rational
  
  [Expand chart above](/assets/typegraphs/RatStr.svg)
  