I have an interface that extends Iterable (as well as other interfaces).
interface MyInterface extends Iterable {
public function iterator ():Iterator<Dynamic>;
}
this gives me
MyInterface.hx:1: lines 1-3 : Invalid number of type parameters for Iterable
what is the correct way to proceed?
Iterable
is defined as atypedef
, not aninterface
, so this can't work.Simply adding a function named
iterator()
to your class will do the trick, no need to implement or extend anything. This mechanism is called structural subtyping.There's more information about Iterators here.