Trying to compile this but I get an ObjectAssigmentError when the items array is assigned.
I want to use B and C for common behavior. What am I doing wrong?
type
A = object of RootObj
name: string
B = object of A
value: string
C = object of A
key: int
let items : seq[A] = @[
B(name:"Test", value:"Value"),
C(name:"Test", key:100)
];
What am I doing wrong?
You're not using ref object:
type
A = ref object of RootObj
name: string
B = ref object of A
value: string
C = ref object of A
key: int