Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type parentObj = ref object of RootObj
- type
- childObj1 = ref object of parentOBj
- childObj2 = ref object of parentOBj
- method whine(self: parentObj) =
- discard
- method whine(self: childObj1) =
- echo "But.... mooooooooooooooooom"
- method whine(self: childObj2) =
- echo "But.... daaaaaaaaaaaaaaaaad"
- var myseq: seq[parentObj] = @[]
- myseq.add(childObj1())
- myseq.add(childObj2())
- var count = 1;
- for obj in myseq:
- obj.whine(count)
- inc(count)
Advertisement
Add Comment
Please, Sign In to add comment