When a Vector is casted like this...
var v1:Vector.<String> = new Vector.<String>();
v1.push("foo");
var v2:Vector.<Object> = Vector.<Object>(v1)
v1.push("bar");
trace(v1); //foo,bar
trace(v2); //foo
... a copy of the Vector is created, as you can see in the trace output.
But when you change line 3 to...
var v2:Vector.<*> = Vector.<*>(v1)
... no copy is created, both v1 and v2 point to the same object, trace outputs will both be "foo,bar".
Why that? Shouldn't there somehow be a consistent behaviour?
No comments:
Post a Comment