Skip to content

Instantly share code, notes, and snippets.

Created October 21, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/87f0f253547ae2fc6404 to your computer and use it in GitHub Desktop.
Save anonymous/87f0f253547ae2fc6404 to your computer and use it in GitHub Desktop.
=head2 What is C<(Any)> and why is it undefined?
In Perl 6 any container got a type. If no type is provided it will default to L<Any|type/Any>. However, any instance of Any is
a defined value.
my $foo;
say $foo.WHAT # "(Any)" whereby the parenteses indicate the type object
say so $foo.DEFINITE; # "False"
my $bar = Any.new;
say $bar.WHAT # "(Any)"
say so $bar.DEFINITE; # "True" as it's an instance of Any
Any type check Perl 6 does will ask C<.DEFINITE> for help. The user level interface are type smilies.
my $foo; # is of Type any and undefined
my Any:D $bar = $foo; # Maybe a runtime or compile time error
sub foo(Any:D $someparam){}
foo($foo); # Maybe a runtime or compile time error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment