In Perl 6, classes are an integral part of the language design. To create a class, use the class keyword. The body of the class, containing its definition, is placed between a pair of curly braces.
Let us start creating a program that uses classes. We'll start with an empty class for a house:
class House {
}
It can be a good practice to begin class names with capital letters. This also agrees with the convention used in Perl 6 itself. Its types are called in the same manner, compare
—Int, Str, Array, and so on.
The preceding code declares a class House and defines its body. Currently, the body is empty, but already you can use this definition to create instances of that class (or, using other terms, create objects of that type).
To some extent, the terms class and type are interchangeable. For example, you can treat strings as instances of the Str class...