Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- PBase = ref object of RootObj
- POne = ref object of PBase
- x: int
- PTwo = ref object of POne
- y: int
- iterator elems(o: PBase): int =
- quit "to override!"
- iterator elems(o: POne): int =
- yield o.x
- iterator elems(o: PTwo): int =
- yield o.x
- yield o.y
- proc printElems(o: PBase) =
- for e in elems(o):
- echo "E: ", e
- printElems(POne(x: 100))
- echo "-----"
- printElems(PTwo(x: 1, y: 2))
Advertisement
Add Comment
Please, Sign In to add comment