开发者

How to create a method that can accept arraylist/collection of object - custom class type in actionscript

开发者 https://www.devze.com 2023-01-17 14:48 出处:网络
Like jav开发者_JAVA百科a, I want to create a method that accepts an array list of particular object type.

Like jav开发者_JAVA百科a, I want to create a method that accepts an array list of particular object type.

In java:

public void addStudents(List<Student> students) {
...
}

In actionscript

public function addStudents(students:ArrayCollection):void {
.....
}

Here I want to have public function addStudents(students:ArrayCollection).

Thanks


If you have a Student object and publish for FP10 you can use the Vector object.

public function addStudents(students:Vector.<Student>):void {}

For further information: http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Vector.html


As far as i know, AS has no template-like generics. But you can extend ArrayCollection into something like StudentArrayCollection with more rigid type check inside.

0

精彩评论

暂无评论...
验证码 换一张
取 消