Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smalltalk: Checking if a method belongs to a class (or its inheritance hierarchy)

Is there a smalltalk message that will answer with a boolean value if a given method (example: passed with #aMethod) belongs to a given class (or its hierarchy)?

I want to say something like —

(self containsMethod:#aMethod) ifFalse:[...blah blah].

Obviously, containsMethod: is a placeholder for some message I hope exists. Oh, and self's superclass in this example is Object. Thanks!

like image 736
Wes Field Avatar asked May 06 '13 11:05

Wes Field


1 Answers

You can use #respondsTo:

1 respondsTo: #+.

and there is the class-side counter part canUnderstand:

1 class canUnderstand: #+.
Integer canUnderstand: #+.
like image 166
camillobruni Avatar answered Oct 16 '22 12:10

camillobruni