
###对delegataion的解释 最使我印象深刻的就是这一段了###
Delegation can be characterized (and distinguished from forwarding) as late binding of self:[3]
… messages sent to the self (or this) variable in the parent will “come back” to the object that originally received the message.
That is, the self in a method definition in the receiving object is not statically bound to that object at definition time (such as compile time or when the function is attached to an object), but rather at evaluation time, it is bound to the original object.
1 |
|
调用b.foo,打印出的是b.bar….这就是delegate的好处,虽然有两个对象,但是this 在此指的是 b.




近期评论