Populating a Vector in the constructor

There is a small difference between populating a Vector while instancing it and an Array.
While an Array is instanced this way:

var names:Array = ["Bob", "Larry", "Sarah"];

a Vector can be instanced like this:

// In the constructor
var names:Vector.<String> = new <String>["Bob", "Larry", "Sarah"];
// Converting from a regular Array using the Vector global (about three times slower)
var names:Vector.<String> = Vector.<String>(["Bob", "Larry", "Sarah"]);

Tags: , , , ,

One Response to “Populating a Vector in the constructor”

  1. Steven Vachon Says:

    Thanks! Was useful for me today