Hi,
I'm looking for answers/clarification on what (if taken as individual
programs) $x is in each case.
my Int $x; # $x is Int protoobject
say $x; # Int
say $x.WHAT; # Int
class Foo { }
my Foo $x; # $x is Foo protoobject
say $x; # Foo
say $x.WHAT; # Foo
# This means we can only assign to $x something that isa Foo?
role Bar { }
my Bar $x; # $x is ???
say $x; # ???
say $x.WHAT; # ???
# This means we can only assign to $x something that does Bar?
subset EvenInt of Int where { $_ % 2 == 0 };
my EvenInt $x; # $x is ???
say $x; # ???
say $x.WHAT; # Failure?
# This means we can only assign to $x something that matches the constraint
class Dog { }
class Cat { }
my Dog|Cat $x; # $x is ???
say $x; # ???
say $x.WHAT; # Failure?
# This means we can only assign to $x something that isa Dog or isa Cat
Thanks,
Jonathan