扩展 Iterable 的 Haxe 接口
Haxe Interface that extends Iterable
我有一个扩展 Iterable 的接口(以及其他接口)。
interface MyInterface extends Iterable {
public function iterator ():Iterator<Dynamic>;
}
这给了我
MyInterface.hx:1: lines 1-3 : Invalid number of type parameters for
Iterable
正确的处理方法是什么?
Iterable
is defined as a typedef
,不是 interface
,所以这行不通。
只需将名为 iterator()
的函数添加到您的 class 即可,无需实施或扩展任何内容。这种机制称为 structural subtyping.
有更多关于迭代器的信息here。
我有一个扩展 Iterable 的接口(以及其他接口)。
interface MyInterface extends Iterable {
public function iterator ():Iterator<Dynamic>;
}
这给了我
MyInterface.hx:1: lines 1-3 : Invalid number of type parameters for Iterable
正确的处理方法是什么?
Iterable
is defined as a typedef
,不是 interface
,所以这行不通。
只需将名为 iterator()
的函数添加到您的 class 即可,无需实施或扩展任何内容。这种机制称为 structural subtyping.
有更多关于迭代器的信息here。