[Cuis-dev] basic question about methods

Mark Volkmann r.mark.volkmann at gmail.com
Sat Jun 1 16:22:53 PDT 2024


Just getting started with Smalltalk ...

I defined the class VRectangle as follows:

Object subclass: #VRectangle
    instanceVariableNames: 'height width'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Playground'

Then I added the class method height:width: like this:

height: aHeight width: aWidth
    | r |
    r := self basicNew.
    r height: aHeight.
    r width: aWidth

Then I added these instance methods:

height: aNumber
    height := aNumber

width: aNumber
    width := aNumber

area
    ^ height * width

Then in a Workspace I did this:

r := VRectangle height: 2 width: 3.
r area.

I get MessageNotUnderstood from the last line, but I don't understand why.
I can inspect r and it looks good.

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240601/9c384c37/attachment.htm>


More information about the Cuis-dev mailing list