[Newbies] Test if a class has a certain selector?

Tobias Pape Das.Linux at gmx.de
Sat Apr 28 00:06:49 UTC 2012

(resend, wrong from: mail)
Am 2012-04-28 um 01:01 schrieb Tobias Pape:

> Am 2012-04-28 um 00:45 schrieb H. Hirzel:
>> Hello
>> Is there a simpler way of writing
>>   Character class selectors includes: #cr
>> (= test if Character class has method  #cr)
> Character canUnderstand: #cr
> remember, its messages,
> =>
> ('a' respondsTo: #first) == (String canUnderstand: #first)

Unless, of course, you really wanted to know whether

	Character class

knows about #cr. But bear in mind, Character class is not
the “class side” of Character but the Metaclass of Character

	Character class isKindOf: Metaclass "=> true"

The “class side” of Character is simply Character

	Character isKindOf: Class "=> true"

The “instance side” of Character is, you know it, 
a character itself

	$a isKindOf: Character "=> true"


So, if you want to know whether the “class side” of
Character knows of the method #cr, the correct one is:

	Character respondsTo: #cr



More information about the Beginners mailing list