Navigation:  Tutorials > Beginners Guide to Smalltalk > Classes and Methods >


Previous pageReturn to chapter overviewNext page

I've already mentioned that methods are chunks of Smalltalk code that describe to an object how a particular message should be processed. Let's look at some of the methods for class Point. With this class selected in the browser, choose <= in the top right methods pane. The browser will bring up and display the Smalltalk source for the method that handles the #<= comparison message for points.

<= anArithmeticValue

       "Answer whether the receiver is neither below nor to the right of anArithmeticValue.

       A double dispatch of #< with the superclass implementation of #<= would not work here."


       | aPoint |

       aPoint := anArithmeticValue asPoint.

       ^x <= aPoint x and: [ y <= aPoint y ]


This method illustrates a few points that we haven't yet touched upon in the Smalltalk code you've written so far. Let's go through these one by one.