-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Neo edited this page May 1, 2022
·
7 revisions
OOlib is a nimble package that can be used for object-oriented programming.
nimble install oolib
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")