I want to make a nested Vector, where i define the length of the nested vector too, someting like this:
var kb:Vector.<Vector.<Number>> = new Vector.<Vector.<Number>(4)>(4); // 4x4 vector
This line throws a compilation error – anyone knows, if this is possible?
The length of a
Vectoris set by a constructor argument. By using generics (type in angle brackets) you can only say that this vector is containing vectors with numbers, like this:The size of nested vectors cannot be limited here since they aren’t initialized. When initializing a vector which will be nested, you can do this:
You could also check the length of a nested vector by overriding every manipulating method of the
Vectorclass within a custom class where you check for the pushed vector’s length.