Front page | perl.perl6.users |
Postings from September 2018
Re: .kv ?
From: Curt Tilmes
September 15, 2018 02:53
Re: .kv ?
Message ID: CAMv20O9KZkyr+25ox2t76VeVNrMbv7cVY7FyxGx32EsweUcgKA@mail.gmail.com
On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo <ToddAndMargo@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;'
> 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
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.