I would like to create a vector in Motoko that can contain different data types symultaneously without creating an abstract type. For instance:
let v : [Any] = ["1",2,"3",4];
It seems that I can do that, but I would like to further constrain it so instead of Any
I am only allowed to use Float
and Text
. Additionally I would like to avoid creating a new abstract type like:
type newtype = {
#number : Float; // variant
#symbol : Text;
};
vv: [newtype] ...
Is it possible to avoid creating the abstract type and still constrain vector content?