First, openArray stands for array or seq, not for string. Well I hope that is 
still the case, it was when I read the tutorial five years ago. I guess one can 
cast a seq[char] to string.

Note that Nim is statically typed, so the return type is well defined at 
compile time. But array type and seq type is very different, you may read that 
section already in my kids book, but it may contain some errors still.

So you can not have a single proc that can return array or seq. Basically you 
need two different procs.

We have "when" keyword in Nim as a compile time "if", and "auto" keyword as a 
possible return type. Both may help that we have to write only one proc, but 
the compiler will instantiate two for us. We have also or-types in Nim, we can 
write "int or float" in the parameter list and the compiler will instantiate 
one proc with int and one with float for us, and in the proc we can test with 
something like "when typeof(x) is float:"

But arrays are not a type but a typeclass, as arrays with same base type but 
different length are incompatible.

So I think there is no solution for you. Can you tell us what you want to 
archive? 

Reply via email to