is Allomorph is Rat
RatStr
is a dual value type, a subclass of both Allomorph
, hence Str
, and Rat
.
See Allomorph
for further details.
my = <42.1>;say .^name; # OUTPUT: «RatStr»my Rat = ; # OK!my Str = ; # OK!# ∈ operator cares about object identitysay 42.1 ∈ <42.1 55 1>; # OUTPUT: «False»
Methods§
method new§
method new(Rat , Str )
The constructor requires both the Rat
and the Str
value, when constructing one directly the values can be whatever is required:
my = RatStr.new(42.1, "forty two and a bit");say +; # OUTPUT: «42.1»say ~; # OUTPUT: «"forty two and a bit"»
method Capture§
method Capture(RatStr: --> Capture)
Equivalent to Mu.Capture
.
method Numeric§
multi method Numeric(RatStr: --> Rat)multi method Numeric(RatStr: --> Rat)
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§
method Rat
Returns the Rat
value of the RatStr
.
method Real§
multi method Real(Real: --> Rat)multi method Real(Real: --> Rat)
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§
infix ===
§
multi infix:<===>(RatStr , RatStr )
RatStr
Value identity operator. Returns True
if the Rat
values of $a
and $b
are identical and their Str
values are also identical. Returns False
otherwise.