> On Sun, May 27, 2018 at 2:49 PM, ToddAndMargo <toddandma...@zoho.com
> <mailto:toddandma...@zoho.com>> wrote:
>
> Hi All,
>
> What is wrong with this picture? Is my
> type being changed or are "Num" and "Rat" in
> a subset of "Real"?
>
> Also, what do I alter to get ^name to say real?
>
> $ p6 'my Real $x= 5e65; say $x.^name'
> Num
>
> $ p6 'my Real $x= 5.5; say $x.^name'
> Rat
>
>
> Many thanks,
> -T
> On 05/27/2018 03:00 PM, Brent Laabs wrote:
Real is a role, not a type. Both Num and Rat happen to do Real, so the
type checking is ok. This would work OK with a type too -- you can
safely store a Num in a `my Cool $foo` as well.
You can't do anything to make the ^name method return Real. There are a
few ways to check this, though. The most idiomatic is smartmatch:
> my Real $f = 3;
3
> $f ~~ Real
True
That checked that the value of the variable does Real. If you want to
check the type of the container:
> $f.VAR.of
(Real)
That explains it. Thank you!