Skip to content
Neo edited this page May 1, 2022 · 7 revisions

Welcome to the OOlib wiki!

OOlib is a nimble package that can be used for object-oriented programming.

Installation

nimble install oolib

Usage

import strformat
import oolib


# add `pub` prefix to publish class
class pub Person:
  var
    name*: string
    age*: int = 0

  # auto insert `self` as first argument
  proc `$`*: string = fmt"<Person> name: {self.name}"

  proc happyBirthday* =
    inc self.age


# auto define constructor
let p = Person.new("myName")
Clone this wiki locally