Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to extend Pharo Smalltalk class behavior?

I want to extend the String class with a method to create a url slug out of a string. I found a link here that shows how you can move extensions to their own package:

Smalltalk Daily 07/13/10: Extending Behavior II.

However, I can't find any "move to package" option in Pharo Smalltalk. Is it ok to just extend the core class with the new method, or is there a better way?

like image 293
xofz Avatar asked Feb 02 '11 01:02

xofz


1 Answers

In Pharo or Squeak put the extension methods for MyPackage in a method category called *mypackage (or if you want to be more descriptive *mypackage-slug).

The methods in these categories belong automatically to the MyPackage package (at least from the Monticello point of view)

like image 102
Alex Jasmin Avatar answered Oct 22 '22 03:10

Alex Jasmin