錯誤信息與vala不同。
Genie的錯誤消息看起來像編譯器的解析問題。 vala的錯誤信息更加清晰。
我在VALA測試:
void main() {
var h = new HashTable<string, int[]> (str_hash, str_equal);
}
錯誤消息:
error: `int[]' is not a supported generic type argument,
use `?' to box value types
看起來像只是不支持 「數組」 和其他各項工作。 'array'不能是任何容器中的元素(HashTable,Array,GenericArray,array ..)
一些測試:所有的作品!
[indent=4]
init
var h = new HashTable of string, HashTable of string, int (str_hash, str_equal)
h["a"] = new HashTable of string, int (str_hash, str_equal)
h["a"]["b"] = 123
stdout.printf ("%d\n", h["a"]["b"])
var a = new HashTable of string, Array of int (str_hash, str_equal)
a["a"] = new Array of int
// a["a"].append_val (456)
// error: lvalue expected
var x = 456
a["a"].append_val (x)
stdout.printf ("%d\n", a["a"].index(0))
var b = new HashTable of string, GenericArray of int (str_hash, str_equal)
b["a"] = new GenericArray of int
b["a"].add (567)
stdout.printf ("%d\n", b["a"].get (0))
var d = new array of Array of int = {new Array of int(), new Array of int}
// ERROR IF {new Array of int, new Array of int}
var y = 321
d[0].append_val (y)
stdout.printf ("%d\n", d[0].index(0))
從一個解釋: http://blog.gmane.org/gmane.comp.programming.vala/month=20140701
不正確了Syntex,它只是不支持。
這並不完全正確,'var h = new HashTable of string,int(str_hash,str_equal)Array'在Genie中有效。所以我首先使用了正確的語法,只是它不適用於簡單的數組。 –