Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace hard tabs with spaces
  • Loading branch information
Paul Cochrane committed Jun 8, 2015
1 parent 87daf4e commit 73c23ee
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/Type/Nil.pod
Expand Up @@ -12,26 +12,26 @@ context.
C<Nil>, when assigned, evaporates into the type object of the type of the
container you assigned it into.
my Int $x = 42;
$x = Nil;
$x.say; # (Int)
my Int $x = 42;
$x = Nil;
$x.say; # (Int)
It is for this reason that assigning an untyped container as C<Nil> will result
in an C<(Any)> object.
my $x = Nil;
$x.say; # (Any)
my Int $y = $x; # error: Type check failed in assignment to '$y'; expected 'Int' but got 'Any'
my $x = Nil;
$x.say; # (Any)
my Int $y = $x; # error: Type check failed in assignment to '$y'; expected 'Int' but got 'Any'
This is because an untyped container is C<Any> until proven otherwise, and
the C<Nil> evaporates.
If you are looking for a variable which transforms objects into type objects
when said variable appears on the RHS, you can type the container as C<Nil>.
my Nil $x;
my Str $s = $x;
$s.say; # (Str)
my Nil $x;
my Str $s = $x;
$s.say; # (Str)
=head1 Methods
Expand All @@ -48,3 +48,5 @@ Returns C<"Nil">.
Returns the empty string.
=end pod

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 73c23ee

Please sign in to comment.