我正在学习Vala编程,收到了此错误消息。
inter.vala:9.55-9.65: error: too few type arguments
public class Totumfaktum : GLib.Object, ITotumfaktum, Traversable {
^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
源代码如下。
使用Gee;
public interface ITotumfaktum : GLib.Object, Traversable {
public abstract int data_1 { get; set; }
public abstract int ret();
public abstract void stat();
}
public class Totumfaktum : GLib.Object, ITotumfaktum, Traversable {
public int data_1 { get; set; }
public int ret() {
stdout.printf("nRETn");
return 0;
}
public void stat() {
return;
}
}
static int main(string[] args) {
Totumfaktum t = new Totumfaktum();
t.ret();
ITotumfaktum s = t;
t.ret();
return 0;
}
Debian 10,Vala 0.42.5
Gee.Traversable
是泛型类型,因此需要提供类型参数。
例如,如果每个元素的类型为int
,则使用Gee.Traversable<int>
。
有关更全面的示例,请查看:https://wiki.gnome.org/Projects/Vala/Manual/Generics