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