Skip to content
AgileLogics
Beginner 4 min read

Classes

Prerequisites: Objects, Functions

A class is a blueprint for creating objects that share the same shape and behavior. An individual object made from a class is called an instance.

Real-world analogy: a class is like a cookie cutter, and each cookie it cuts is an instance — same shape, but each cookie is its own separate cookie.

class User:
    name
    function greet():
        return "Hi, I'm " + this.name

ada = new User("Ada")
ada.greet()   # "Hi, I'm Ada"

This grouping of data and behavior together is called object-oriented programming, covered in depth once you're inside a specific language.