I want to write a method that checks the list of all the superclasses ( allSuperclass method) and returns 'true' if one of them has a classVariable with a specific name. If none of them have it it'll return false. How do I do this?
classVarNames
is a method that returns a collection of the class variable names.
For example, if you'll add this method to Behavior class you should get a functionality you're asking for:
superclassesHaveNoClassVar: name
^ self allSuperclasses noneSatisfy: [:class |
class classVarNames includes: name]
Nothing special. Just take allSuperclasses
and check if none of them includes
a desired variable name
among it's classVarNames
.