Search code examples
classcategoriessmalltalkpharo

Adding Categories to Classes in Pharo 9.0 (Smalltalk)


I've very recently started learning Pharo Smalltalk and my first assignment requires me to add three categories to a class, but the problem is that any information I find on the web is written before 2014, and the options are just not there anymore. How can I add categories to classes in Pharo 9.0?


Solution

  • I presume that the assignment consists in adding categories programmatically. In that case, this is how you could learn how to add a category.

    1. Find the class you want to add the category to
    2. Inspect the class and take a look to its instvars
    3. The categories of the class should be there somehow
    4. The ivar whose name looks promising is organization
    5. Its class is ClassOrganizer
    6. Check to see whether there is a ClassOrganizerTest for testing it
    7. Found! Take a look at the tests and see if you can find what you are looking for.