【发布时间】:2016-01-11 08:34:03
【问题描述】:
我写了一个代码,它是关于 GLib.Tree 的。但是不知道怎么用搜索方法。
Valadoc 有一个例子,并且有效!
下面是我的代码:
[indent = 4]
def cmp (a: string, b: string): int
return strcmp (a, b)
init
var t = new Tree of string, string (cmp)
t.insert ("a", "aaa")
t.insert ("b", "bbb")
var needle = "A"
fun: TreeSearchFunc = def (k)
return strcmp (k.down(), needle.down())
var ret = t.search (fun)
错误!
错误:名称
down' does not exist in the context ofK'
再试一次:
fun: TreeSearchFunc of string = def (k)
错误!
错误:“GTreeSearchFunc”未声明
TreeSearchFunc 说明:
public delegate int TreeSearchFunc (K key)
如果我想写一个 TreeSearchFunc 委托? 该怎么做?
【问题讨论】: