Skip to content

Commit

Permalink
be precise where the default type constraint actually comes from
Browse files Browse the repository at this point in the history
  • Loading branch information
gfldex committed Dec 1, 2016
1 parent c7b14ae commit 0bf8b18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/Language/variables.pod6
Expand Up @@ -843,16 +843,16 @@ unsuccessfully, resetting the answer to 42.
=head1 Type Constraints and Initialization
Variables can have a type constraint, which goes between the declarator and
the variable name.
Variables have a type constraint via the L<container|/language/containers> they
are bound to, which goes between the declarator and the variable name. The default type constraint is L<Mu|/type/Mu>
my Int $x = 42;
$x = 'a string';
CATCH { default { put .^name, ': ', .Str } }
# OUTPUT: X::TypeCheck::Assignment: Type check failed in assignment to $x; expected Int but got Str ("a string")
If a scalar variable has a type constraint but no initial value, it is
initialized with the type object of the constraint type.
initialized with the type object of the default value of the container it is bound to.
my Int $x;
say $x.^name; # Int
Expand Down

0 comments on commit 0bf8b18

Please sign in to comment.