Created
February 22, 2015 00:44
-
-
Save G4MR/372747924cc26927f089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MyObj = ref object of RootObj | |
method output(self: ref MyObj) = | |
echo "Output something" | |
type ChildObj = ref 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