Hello again,
I'm having some trouble conditioning on type with generics. Here is a minimal example of what I'm trying to do (no generics but same goal):
type
Foo = object
a: array[4, float32]
b: float32
for name, value in Foo().fieldPairs():
echo name
if value is array:
echo value.len()
echo "------------"
I get the following error:
/usercode/in.nim(11, 15) Error: type mismatch
Expression: len(Foo().b)
[1] Foo().b: float32
I think I might be able to get around it with templates but I'd like to avoid that if possible.
In general what is the idiomatic way to define type-conditional behaviour with generics?