On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo <toddandma...@zoho.com> wrote:

> When I said "yet", I presumed the a variable can be
> redefined at will:
>
> $ p6 'my $x; say $x.perl;
>           $x="abc"; say $x.perl;
>           $x=Nil; say $x.perl;'
> Any
> "abc"
> Any
>
> And that the receiving method only cares what you feed it
> at the time it is called.
>

Your example doesn't limit the type.  If you limit the type, you'll get an
error
by assigning it something the type doesn't allow.

my Int $x;
$x = "abc"; # error can't put a string in an Int

my Int:U $x;
$x = 42; # error can't put a definite value in an Int:U

my Int:D $x = 42;
$x = Nil;   # error, can't undefine.

You're only allowed to put in things that fit.  If an argument to a routine
is limited, you can only pass in things that fit.

Curt

Reply via email to