Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update Nil.pod6
At first glance, it seems that Nil can be assigned to any container. Extra explanation for hash assignment.
  • Loading branch information
finanalyst committed Oct 19, 2018
1 parent 233cfa5 commit eaf115c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion doc/Type/Nil.pod6
Expand Up @@ -53,7 +53,15 @@ C<Nil>.
X<|Nil assignment>
When assigned to a L<container|/language/containers>, the C<Nil> value (but not any subclass of
C<Nil>) will attempt to revert the container to its default value; if no
such default is declared, Perl 6 assumes C<Any>. However, if the container
such default is declared, Perl 6 assumes C<Any>.
Since a hash assignment expects two elements, use C<Empty> not C<Nil>, eg.
my %h = 'a'..'b' Z=> 1..*;
# stuff happens
%h = Empty; # %h = Nil will generate an error
However, if the container
type is constrained with C<:D>, assigning C<Nil> to it will immediately throw
an exception. (In contrast, an instantiated C<Failure> matches C<:D>
because it's a definite value, but will fail to match the actual nominal
Expand Down

0 comments on commit eaf115c

Please sign in to comment.