Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道已经有很多关于 的问题self,但我只是想确保我已经理解它。
self
def buttonPressed @action.call(self) end
在这段代码中,self指的是@action(因为@action是调用方法的接收者)。是对的吗?
@action
{ songList.start }
如果 proc 对象没有像这种情况下的参数,为什么要prc.call self作为参数给出?
prc.call self
I. 在类之外,self返回maintype Object。在类内部,它将返回该类的当前实例。
main
Object
二、在这个特定块的情况下,确实不需要self传递,但传递self意味着您也可以潜在地拥有action可以访问的 s self。
action