Try this.
type
A = ref object of RootObj
B = ref object of A
val:int
proc example*(x:seq[A]) =
for i in x:
echo repr i
var a:seq[A] = @[B(val:1).A, B(val:2),A()] #B(val:1).A instead of #B(val:1)
echo repr a
example(a)
for item in a:
if item of B:
echo repr B(item)
Run
Now you've created a seq[A] instead of seq[B].
The of operator here is used to check if an item is of type B at runtime.
You might want to look into methods. It's under the header multi-methods in the
manual.
[https://nim-lang.org/docs/manual.html#multiminusmethods](https://nim-lang.org/docs/manual.html#multiminusmethods)