Language Reference

Classes

Model objects with classes, methods, and inheritance using plain statements.

Class essentials

  • Create classes with create a class named.
  • Add methods with create a method named.
  • Extend with extends.

Define classes

Declare classes and add methods inside the class block.

classes.pln
create a class named Person
    create a method named greet in class Person that takes nothing and returns "Hello"

create a class named Student that extends Person
    create a method named study in class Student that takes nothing and returns "Studying"

Working with instances

Once the class is defined, use normal Python-style calls for instantiation.

instances.pln
set student to Student()
print student.greet()
print student.study()

Class tips

  • Use classes to bundle data with behavior.
  • Keep class names capitalized.
  • Prefer composition for large systems.