ArrayAccess

You are viewing an old version of this entry, click here to see latest version.
extern interface ArrayAccess<T>import StdTypesAvailable in flash, flash9, neko, js, phpAn object of a class that implements this interface can be used with the [] operator syntax (also known as "array access" syntax), in the manner similar to how Array objects are used with it. The operator takes an integer parameter (in the square brackets) and returns elements of type T.

Example

//Following is a snippet from the standard Haxe library

package flash.xml;

extern class XMLList implements ArrayAccess<XML>

In accordance with the above declaration, all XMLList objects can be used with the following syntax:

var xml_list_obj: XMLList;

//...

/* Note that the [] operator implementation for the XMLList class 
is part of the appropriate platform in this case. */

var xml_obj:XML = xml_list_obj[10]; //Return 10th XML node in the list
version #6338, modified 2009-07-15 17:41:17 by amn
0 comment