••• Unprocessable paragraph: \start
Home Segments Index Top Previous Next

547: Mainline

\slidefont

Because you can define your own binary methods, you can create new numberlike object classes. For example, you can create a Weight class for representing weights. Once you have defined such a class, you do not need to use ordinary Number instances for weights; instead, you can use Weight instances, and can perform calculations using those instances as receivers, such as the following, in which gm is an abbreviation for grams:

••• Unprocessable paragraph: \begincode 3gm + 2gm <– Answers 5gm 3gm < 2gm <– Answers false \par C:\Phw\Onto\Smalltalk\overload.tex ••• C:\Phw\Onto\Smalltalk\overload.tex •••