ActionScript 3 Vector.<T> VS. Array
This question if a bit off topic, I just wanted feedback from most ActionScript/Flex developers out there.
So would you use a Vector. rather than an Array when you're expecting a collection of the same "type" of objects (and publishing for fp10)
Let me clear that out :
I'm defining a method in a class that expects one parameter of type "Array"
Let's say the method's signature looks like this :
public function doSomethingWithChildren(selectedChildren:Array):void;
I'm expecting that all the elements in the "selectedChildren" Array are of type "DisplayObject" (even thought it seems quite logical), so I thought that it would be a bit smarter to re-write this function this way :
pub开发者_如何学编程lic function doSomethingWithChildren(selectedChildren:Vector.<DisplayObject>):void;
So, basically the only thing I'd like to know is if you think this is the way to go
Thanks for yer feedback
yes, this would be the way to go because now you have the extra static type checking and information. I believe typed vectors are also faster than arrays.
精彩评论