Navigation Menu

Skip to content

Commit

Permalink
mention .defined, and that type objects are undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Sep 26, 2010
1 parent e76fe15 commit 8134ba9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/classes-and-objects.pod
Expand Up @@ -71,6 +71,8 @@ Which package?
=end for

X<type object>
X<defined>
X<.defined>

Declaring a class creates a I<type object>, which by default gets installed
into the package (just like a variable declared with C<our> scope). This type
Expand All @@ -80,6 +82,21 @@ Perl 6 built-in classes. The example uses the class name C<Task> so that other
code can refer to it later, such as to create class instances by calling the
C<new> method.

Type objects are I<undefined>, in the sense that they return C<False> 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<attributes>
Expand Down

0 comments on commit 8134ba9

Please sign in to comment.