[Newbies] Best way to implement two-dimensional array

Bert Freudenberg bert at freudenbergs.de
Tue Sep 4 17:36:21 UTC 2007

On Sep 4, 2007, at 10:07 , John Almberg wrote:

> Bert,
>> Well, since you are storing it in a class var, the "heavy lifting"  
>> can be done at initialization time. This way the code remains  
>> readable but you can do heavy pre-processing to bring that stuff  
>> into an easily accessible form.
> Oh! I see what you mean. That would be a good approach.
>> Btw, the "real" Smalltalk way would be to just create your data in  
>> the class var interactively using an inspector. The image will  
>> store these just fine. The problem with there may not be a simple  
>> way of transporting them along with the code into another image.
> H'mmm... this is over my head. I'm not sure how to inspect a class  
> object.
> I tried doing:
> 	MyClass inspect
> and also poking around the menus, but it looks like I'm inspecting  
> an instance of the class, not the class itself -- the class  
> variable is not displayed.
> How do you edit data in a class interactively? Probably not what I  
> want, as you say, but sounds interesting.

Type "MyClass", select it, press Cmd-i (or Alt-i). You get an  
inspector on a class - which of course is the instance of another  
class, as everything is an object (and hence an instance of a class)  
in Smalltalk. Anyway, you should see a reference to the superclass, a  
dictionary of all the methods, the list of instance variables and  
subclasses etc. Class variables are simply held in a Dictionary in  
the "classPool" instance variable of that class. So by inspecting  
that and drilling down into your class var you can modify it.

A simpler way to get at the contents of your class var is just  
selecting its name in a browser showing any method of your class, and  
press Cmd-i there. That works because in the browser, code is  
evaluated in the context of the selected class.

- Bert -

More information about the Beginners mailing list