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 a typedef
, not an interface
, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With