views:

383

answers:

1

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 :

public 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

A: 

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.

CookieOfFortune
Thanks Cookie, it's always nice getting someone else's advice
just_a_dude