I have an object defined like this:
Obj = ref object
case kind: ObjKind:
of typeA, typeB: contents: seq[Obj]
else: discard
Run
Then I create an object like that:
example = Obj(kind: typeA, contents: @[some contents])
Run
at some point, let's say I decide to change the object's kind (but without
changing its _contents_ field). I do it like this:
.kind = typeB
Run
Now, it seemingly works fine. The problem is the contents field's contents are
gone (the only way to get them back is by keeping a copy of the previous
contents, change the kind and re-set the contents).
Any idea what is going on or what the best way to do it would be?