I'm trying to extend the SmallInteger class with a new instance method "square". The idea is I wanna be able to call "5 square" and it'll return 25.
Extending your own classes with instance methods is fairly simple, since you know the variable names, but I don't know the variable names in the SmallInteger class. How can I find them?
I'm thinking it should look something like this, but 'thisNumber' is referencing whatever number this SmallInteger object happens to be.
SmallInteger extend [
square [
| r |
r := thisNumber * thisNumber.
^r
]
]