Haxe Interface Extending Iterable

I have an interface extending Iterable (as well as other interfaces).

interface MyInterface extends Iterable {
  public function iterator ():Iterator<Dynamic>;
}

it gives me

MyInterface.hx: 1: lines 1-3: Invalid number of type parameters for Iterable

What is the right way?

+4
source share
1 answer

Iterabledefined as , not how , so this cannot work. typedefinterface

Just adding a function with a name iterator()to your class will help; you don’t need to implement or extend anything. This mechanism is called a structural subtype .

There is more information about iterators here .

+7
source

All Articles