| Tags articlescollectionstutorialActiveTuts+ActionSctipt3 |
| 6 October 2011 |
A new tutorial about work with Collections in ActionScript 3 with Realaxy Editor was recently published on ActiveTuts+.
Requirements
Program: Realaxy ActionScript Editor Beta 10 (build 8179+)
Difficulty: Intermediate
Estimated completion time: 20 min.
Good news everyone. Everybody who works with arrays and vectors - it pretty seems, all developers do it - will enjoy the new opportunities: since the late August 2011 (build 8179+), Realaxy ActionScript Editor (RASE) supports the new Collections AS3 language extension. In this post we’ll tell you about its potentials.

A collection is a general term that means something like “a bunch of similarly typed objects that are grouped together”. Building a collection in ActionScript 3.0 can be done by using either arrays or vectors. They both have some makings of a perfect concept. However, if you have even a basic acquaintance with any modern and trendy language like Scala, Groovy or Ruby, you’ll definitely feel the lack of a functional approach in the pure AS3-way of processing Collections.
Well, let’s introduce the Collections AS3 language extension that is available in RASE Beta 10, build 8177+.

A complete vocabulary of methods supplemented with samples is available here: one for lists and another one for maps (scroll them down, they are really HUGE).
In order to not get lost in this jungle, let’s take a survey on some simple use case. The first true-life sample demonstrates the conciseness of a code.
We create a list, which can contain only int values.
where”).select”).select”).list and to trace the result.
Where, select, selectMany — these operations are easy to use when you’re building a query.

Operations like all, any, containsAll, contains work perfectly in conditional phrases (“if” statement, etc).

To modify a list, go ahead to use a wide range of weapons — remove, removeAll, removeWhere, removeHead, removeTail, etc.

For those persons who definitely have an eye for perversion :D we have prepared a bunch of operations like foldLeft/foldRight, reduceLeft/reduceRight, intersect, etc.
Simply said, there are a plenty of various operations suited to every fancy and almost every task. In some operations you just transmit one or more values to it, in some other ones you add a closure.
Read and discuss the full article on ActiveTuts+.