In Glossary§
See primary documentation in context for Instance
An instance of a class is also called an object in some other programming languages. It has storage for attributes and is often the return value of a call to a method called new
, or a literal.
Instances of most types are defined to be True
e.g., defined($instance)
is True
.
my Str $str = "hello"; ## this is with built-in types, e.g. Str if defined($str) { say "Oh, yeah. I'm defined."; } else { say "No. Something off? "; } ## if you wanted objects... class A { # nothing here for now. } my $an_instance = A.new; say $an_instance.defined.raku;# defined($an_instance) works too.
To put things another way, a class contains the blueprints of methods and attributes, and an instance carries it into the real world.