Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Forked from G4MR/gist:43718393b67128450dcf
Created February 22, 2015 00:40
Show Gist options
  • Save fowlmouth/74bd31089c0cd3545f26 to your computer and use it in GitHub Desktop.
Save fowlmouth/74bd31089c0cd3545f26 to your computer and use it in GitHub Desktop.
type MyObj = ref object of RootObj
method output(self: MyObj) =
echo "Output something"
type ChildObj = ref object of MyObj
customvar: string
method newOutput(self: ChildObj) =
self.customvar = "Child output custom var too"
method output(self: ChildObj) =
echo "Child Output something too"
self.newOutput()
echo self.customvar
var o = MyObj()
var ochild = ChildObj()
var objs : seq[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