Skip to content

Instantly share code, notes, and snippets.

@G4MR
Created February 22, 2015 00:35
Show Gist options
  • Save G4MR/43718393b67128450dcf to your computer and use it in GitHub Desktop.
Save G4MR/43718393b67128450dcf to your computer and use it in GitHub Desktop.
type MyObj = object of RootObj
method output(self: ref MyObj) =
echo "Output something"
type ChildObj = object of MyObj
customvar: string
method newOutput(self: ref ChildObj) =
self.customvar = "Child output custom var too"
method output(self: ref ChildObj) =
echo "Child Output something too"
self.newOutput()
echo self.customvar
var o = new(MyObj)
var ochild = new(ChildObj)
var objs : seq[ref MyObj] = @[]
objs.add(o)
objs.add(ochild)
for o in objs:
o.output()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment