Skip to content

Instantly share code, notes, and snippets.

@scizzorz
Created February 27, 2015 23:12
Show Gist options
  • Save scizzorz/91f00f0635fe5595f7d1 to your computer and use it in GitHub Desktop.
Save scizzorz/91f00f0635fe5595f7d1 to your computer and use it in GitHub Desktop.
Testing nim constructors
type Person = object
name: string
type Animal = object
kind: string
proc new(this: type Person, name: string): Person =
result.name = name
proc new(this: type Animal, kind: string): Animal =
result.kind = kind
var p = new(Person, "Hello!")
var a = Animal.new("Bear")
var b = Animal.new "Bunny"
echo(p.name)
echo(a.kind)
echo(b.kind)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment