If I say "my Int $x",
$x is now an Int, but an undefined Int.
If I say "my Int $x = 42",
$x is an Int, but set to a defined value, 42.
Both are Int:
say 42 ~~ Int; # OUTPUT: «True␤»
say Int ~~ Int; # OUTPUT: «True␤»
There are three type constraint suffixes you can add -- :D (defined), :U
(undefined) or :_ (defined or undefined)
# Checking a type object
say Int ~~ Any:D; # OUTPUT: «False␤»
say Int ~~ Any:U; # OUTPUT: «True␤»
say Int ~~ Any:_; # OUTPUT: «True␤»
# Checking an object instance
say 42 ~~ Any:D; # OUTPUT: «True␤»
say 42 ~~ Any:U; # OUTPUT: «False␤»
say 42 ~~ Any:_; # OUTPUT: «True␤»
On Fri, Sep 14, 2018 at 7:08 AM Todd Chester <toddandma...@zoho.com> wrote:
> On 09/14/2018 04:01 AM, Simon Proctor wrote:
> > :D is a type constraint requiring an instantiated (or defined) object of
> > the given type (or a subtype of it).
> > :U is a type constraint saying you have a container specified for the
> > given type that hasn't been instantiated.
> Hi Simon,
> Your went over my head. What the heck is "instantiated"?
> verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.
> to provide an instance of or concrete evidence in support
> of (a theory, concept, claim, or the like).
> I am not connecting the dots.
> Is there a list of these guys somewhere, or are these the only two?