txt: ## numstr.md
  class NumStr
  
  Dual value floating-point number and string
  
  ```raku
  class NumStr is Allomorph is Num { }
  ```
  
  `NumStr` is a dual value type, a subclass of both [`Allomorph`](/type/Allomorph), hence [`Str`](/type/Str), and [`Num`](/type/Num).
  
  See [`Allomorph`](/type/Allomorph) for further details.
  
  ```raku
  my $num-str = <42.1e0>;
  say $num-str.^name;         # OUTPUT: «NumStr␤»
  
  my Num $num = $num-str;     # OK!
  my Str $str = $num-str;     # OK!
  
  # ∈ operator cares about object identity
  say 42e10 ∈ <42e10  55  1>; # OUTPUT: «False␤»
  
  ```
  
  # [Methods](#class_NumStr "go to top of document")[§](#Methods "direct link")
  
  ## [method new](#class_NumStr "go to top of document")[§](#method_new "direct link")
  
  ```raku
  method new(Num $i, Str $s)
  ```
  
  The constructor requires both the [`Num`](/type/Num) and the [`Str`](/type/Str) value, when constructing one directly the values can be whatever is required:
  
  ```raku
  my $f = NumStr.new(42.1e0, "forty two and a bit");
  say +$f; # OUTPUT: «42.1␤»
  say ~$f; # OUTPUT: «"forty two and a bit"␤»
  ```
  
  ## [method Num](#class_NumStr "go to top of document")[§](#method_Num "direct link")
  
  ```raku
  method Num
  ```
  
  Returns the [`Num`](/type/Num) value of the `NumStr`.
  
  ## [method Numeric](#class_NumStr "go to top of document")[§](#method_Numeric "direct link")
  
  ```raku
  multi method Numeric(NumStr:D: --> Num:D)
  multi method Numeric(NumStr:U: --> Num: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 `0e0`.
  
  ## [method Real](#class_NumStr "go to top of document")[§](#method_Real "direct link")
  
  ```raku
  multi method Real(NumStr:D: --> Num:D)
  multi method Real(NumStr:U: --> Num: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 `0e0`.
  
  # [Operators](#class_NumStr "go to top of document")[§](#Operators "direct link")
  
  ## [infix `===`](#class_NumStr "go to top of document")[§](#infix_=== "direct link")
  
  ```raku
  multi infix:<===>(NumStr:D $a, NumStr:D $b)
  ```
  
  `NumStr` Value identity operator. Returns `True` if the [`Num`](/type/Num) 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 `NumStr`
  
  
  
  raku-type-graph
  
  
  
  NumStr
  NumStr
  
  
  Allomorph
  Allomorph
  
  
  NumStr->Allomorph
  
  
  
  Num
  Num
  
  
  NumStr->Num
  
  
  
  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
  
  
  
  Num->Cool
  
  
  
  Num->Real
  
  [Expand chart above](/assets/typegraphs/NumStr.svg)
  