`type Parent = ref object of RootObj parentField: int Child = ref object of Parent childField: string # Using generics proc newParent(T = typedesc[Parent], value = 123): T = new result result.parentField = value proc newChild(value: string): Child = result = newParent(Child, 321) result.childField = value var parent = newParent() child = newChild "ABC" echo "parent parentField: ", parent.parentField echo "child parentField : ", child.parentField echo "child childField : ", child.childField `
Run