VectorArgRest

Documentation for the VectorArgRest type

The VectorArgRest type represents all valid rest parameters types that can be used to construct a Vector

This is the exact definition of VectorArgRest:

type VectorArgRest<D extends number = any> = [number] | number[] | [number[]] | [Vector<D>];

Which can be read as follows:

Anywhere VectorArgRest is required, you can use either:

  • a number

  • an array of numbers

  • a tuple composed by a single array of numbers

  • a Vector

Which in practice means:

// ...
function myFunction(...param: VectorArgRest){
  // ...
};

myFunction(1);            // a number
myFunction(1,2,3);        // an array of numbers (spread as rest parameters)
myFunction([1,2,3]);      // a tuple composed by an array of numbers
myFunction(new Vector()); // a Vector

You can use the static convertToSameDimVector method to turn VectorArgRest into a Vector of a desired dimension

Last updated

Was this helpful?