Inheritance Smalltalk:检查方法是否属于类(或其继承层次结构)
如果给定的方法(例如:用#aMethod传递)属于给定的类(或其层次结构),是否有一条smalltalk消息将用布尔值来回答 我想说-Inheritance Smalltalk:检查方法是否属于类(或其继承层次结构),inheritance,methods,smalltalk,squeak,gnu-smalltalk,Inheritance,Methods,Smalltalk,Squeak,Gnu Smalltalk,如果给定的方法(例如:用#aMethod传递)属于给定的类(或其层次结构),是否有一条smalltalk消息将用布尔值来回答 我想说- (self containsMethod:#aMethod) ifFalse:[...blah blah]. 显然,containsMethod:是我希望存在的某些消息的占位符。哦,在这个例子中self的超类是Object。谢谢 您可以使用响应: 1 respondsTo: #+. 还有一个类边计数器部件可以理解: 1 class canUnderstand
(self containsMethod:#aMethod) ifFalse:[...blah blah].
显然,containsMethod:是我希望存在的某些消息的占位符。哦,在这个例子中self的超类是Object。谢谢 您可以使用响应:
1 respondsTo: #+.
还有一个类边计数器部件可以理解:
1 class canUnderstand: #+.
Integer canUnderstand: #+.
非常感谢。非常感谢。注意层次结构搜索类端等价物是
#canUnderstand:
是否仅针对类本身?不查看继承层次结构?我需要一个方法来回答类是否有特定的方法,您可以执行Integer includeselector:#asNumber
这将返回false
,因为#asNumber
只在Number
中实现,Integer
@camillobruni的超类感谢IncludeSelector:我正在搜索它。为了将来参考,Squeak's有一个很棒的示例搜索功能。查询对象是新的#阿斯特林。正确。
查找#响应:
和一些其他消息。