ActionScriptのArrayクラスとVectorクラスには、どちらもslice()メソッドがあります。パラメータを渡さない場合、新しい配列またはベクトルは元のベクトルの複製(浅いクローン)になります。
「浅いクローン」とはどういう意味ですか?具体的には、の違いは何ですか
Array newArray = oldArray.slice();
Vector.<Foo> newVector = oldVector.slice();
と
Array newArray = oldArray;
Vector.<Foo> newVector = oldVector;
?また、Vectorの基本型がFooではなく、intのような単純で不変なものである場合はどうなりますか?
アップデート:
次の結果はどうなりますか?
var one:Vector.<String> = new Vector.<String>()
one.push("something");
one.push("something else");
var two:Vector.<String> = one.slice();
one.push("and another thing");
two.push("and the last thing");
trace(one); // something, something else, and another thing
trace(two); // something, something else, and the last thing
ありがとう!♥</p>