GNU Smalltalk User's Guide
4.8.3 Looking at Objects
When you are chasing an error, it is often helpful to
examine the instance variables of your objects. While
strategic calls to
printNl will no doubt help, you can look at an
object without having to write all the code yourself. The
inspect message works on any object, and dumps out the
values of each instance variable within the object.(32)
Smalltalk at: #x put: (Interval from: 1 to: 5) !
x inspect !
An instance of Interval
We'll finish this chapter by emphasizing a technique
which has already been covered: the use of the
message in your own objects. As you saw in the case of Dictionary,
an object can send itself an
error: message with a
descriptive string to abort execution and dump a stack backtrace.
You should plan on using this technique in your own
objects. It can be used both for explicit user-caused
errors, as well as in internal sanity checks.