[Newbies] Best way to implement two-dimensional array

Blake blake at kingdomrpg.com
Sun Sep 2 22:45:55 UTC 2007


John,

	You know, I've asked this a number of times and there's a neglected 2D  
array class, but I've found you don't really need it. You can just use a  
dictionary:

	aDict at:x at y put:anObject
	anObject := aDict at:x at y

	It sort of rubs me the wrong way but it's workable.

	===Blake===

On Sun, 02 Sep 2007 05:45:42 -0700, John Almberg <jalmberg at identry.com>  
wrote:

> This is a smalltalk question, but hopefully not too off-topic...
>
> I need a lookup table object... something to which I can send a message  
> like:
>
> anElement := myTable index1: #aSymbol index2: #anotherSymbol
>
> The underlying structure is actually a table... rows and columns... and  
> I want to be able to fetch elements in the table.
>
> I am thinking myTable should hold a dictionary of dictionaries, (a hash  
> of hashes, I might say if using another language), but I am wondering if  
> there is a more smalltalk-ish way to do this?
>
> Any suggestions much appreciated.
>
> -- John
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners




More information about the Beginners mailing list