Vala 教程有一个关于使用匿名方法的 DBus的示例。
Bus.own_name (BusType.SESSION, "org.example.DemoService", /* name to register */
BusNameOwnerFlags.NONE, /* flags */
on_bus_aquired, /* callback function on registration succeeded */
() => {}, /* callback on name register succeeded */
() => stderr.printf ("Could not acquire name\n")); /* callback on name lost */
我正在尝试在 Genie 中重写此代码,但无法转换最后两行。Genie 教程只有一个关于如何使用闭包来定义事件处理程序的示例。
f.my_event += def (t, a)
print "event was detected with value %d", a
如何在使用 Genie 的方法调用中使用匿名方法定义?