diff --git a/src/classes-and-objects.pod b/src/classes-and-objects.pod index b1772e1..d6a50e8 100644 --- a/src/classes-and-objects.pod +++ b/src/classes-and-objects.pod @@ -71,6 +71,8 @@ Which package? =end for X +X +X<.defined> Declaring a class creates a I, which by default gets installed into the package (just like a variable declared with C scope). This type @@ -80,6 +82,21 @@ Perl 6 built-in classes. The example uses the class name C so that other code can refer to it later, such as to create class instances by calling the C method. +Type objects are I, in the sense that they return C if you +call the C<.defined> method on them. You can use this method to find out if a +given object is a type object or not: + +=begin programlisting + + my $obj = Int; + if $obj.defined { + say "Type object"; + } else { + say "Ordinary, defined object"; + } + +=end programlisting + =head1 I can has state? X