Navigation:  Tutorials > Beginners Guide to Smalltalk > Programming in Smalltalk >

Creating a class

Previous pageReturn to chapter overviewNext page

Let's now create the Animal class as a subclass of Object. To do this, select the superclass Object in the Class Browser and choose Class/New. You will be prompted to enter a name for the class you want to create; in this case Animal. For the moment you should uncheck the Packaged? check box; we will package the new class later in this chapter.


Click OK and you'll see that the browser has created your class and will also display a Smalltalk definition of it in the Class definition pane at the bottom.

Tip: The area at the bottom of the Class Browser can display of one of several panes depending on which tab is selected.

At present the Class definition pane will have been selected automatically to show you the definition of the class that has just been created. We hinted in the previous chapter that the contents of this pane contains a Smalltalk expression that could be evaluated in any workspace to create the class. Look closely and you'll see that the message #subclass:instanceVariableNames:classVariableNames:poolDictionaries: is being sent to Object in order to do this. It's convenient that the browser saves us the typing and composes and evaluates this expression for us.