Why are you trying to create such a thing?
I am sure you could make such thing in nim (you can do anything in nim). Buy
why?
I think the reason its hard to do such a thing is that nim is trying to say
don't do it this way.
If you know the type of array at compile time just use:
var ma = newSeq[float](rows)
Run
If you don't, use a case object:
type
OddArrayKind = enum
OddInt, OddFloat
OddArray* = ref object
case kind: OddArrayKind
of OddInt:
intSeq: seq[int]
of OddFloat:
floatSeq: seq[float]
proc createMyArray(length: int, strSind: string): OddArray =
if strSind == "int":
OddArray(kind: OddInt, intSeq: newSeq[int](length))
else:
OddArray(kind: OddFloat, floatSeq: newSeq[float](length))
var rows = 23
var ma = createMyArray(rows, "float")
Run
I would strongly suggest creating the intSeq or the floatSeq and passing that
around instead of doing case objects and these odd string types.