最近,我开始学习iolanguage。尝试“方法”消息时,我写道:
Io> f := method(getSlot("f"))
==> method(
getSlot("f")
)
Io> slotSummary
==> Object_0x97f41a8:
Lobby = Object_0x97f41a8
Protos = Object_0x97f4090
_ = nil
exit = method(...)
f = method(...)
forward = method(...)
set_ = method(...)
Io> f
==> nil
但是,为什么调用f会返回nil而不是“ f”本身呢?
根据指南, method()
介绍了一个用于存储本地对象的对象,并将本地self
指针设置为消息的目标。因此,目标没有插槽,但我们可以使它们通过self
:
Io> f := method(self getSlot("f"))
==> method(
self getSlot("f")
)
Io> f
==> method(
self getSlot("f")
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句