api/iterable/examples [en]

All languages

Differences between version #8034 and #8041

0a1,29
> You can iterate over your own Data Structures, by providing an iterator function.
> <code haxe>
> class MyClass 
> {
>     public var names:Array<String>;
> 
>     public function new () 
>     {
>         names = ["ted", "fred", "tim"];
>     }
> 
>     public function iterator ()
>     {
>         return names.iterator();
>     }
> }
> 
> class Test
> {
>     public static function main ()
>     {
>         var myInstance = new MyClass();
> 
>         for (i in myInstance)
>             trace(i); // ted, fred, tim
>     }
> }
> </code>
> 
6a36
> 

	
Ver Date User Action
#15547 2012-10-05 03:06:29 JLM View | Diff
#15531 2012-09-25 15:38:44 jan_flanders View | Diff
#8041 2010-02-05 18:28:43 hhoelzer View | Diff
#8034 2010-02-05 14:10:32 hhoelzer View | Diff
#8033 2010-02-05 13:55:58 hhoelzer View | Diff
#8032 2010-02-05 13:51:44 hhoelzer View | Diff
#8030 2010-02-05 13:49:07 hhoelzer View | Diff
#8029 2010-02-05 13:49:07 hhoelzer Set title to Examples

Previous | Next