priyank
priyank

Reputation: 4724

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

Like java, 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

Upvotes: 0

Views: 206

Answers (2)

Tobias Golbs
Tobias Golbs

Reputation: 4616

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

Upvotes: 3

Martin
Martin

Reputation: 434

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.

Upvotes: 1

Related Questions