[Newbies] f(x, y) or Table

Ron Teitelbaum ron at usmedrec.com
Thu Apr 14 16:26:22 UTC 2016


Hi Joseph,

| aPoint aDictionary |

aPoint := Point x: 1 y: 2.
aDictionary := Dictionary new.
aDictionary at: aPoint put: 'Success!'.
^aDictionary at: aPoint

Everything in Smalltalk is an object.  You can use a number or string as
your dictionary key but you can also use more complex objects like a Point.

The object matching is implemented in #=.  If the objects match then the
value will be returned.  

All the best,

Ron Teitelbaum

> -----Original Message-----
> From: beginners-bounces at lists.squeakfoundation.org [mailto:beginners-
> bounces at lists.squeakfoundation.org] On Behalf Of Joseph Alotta
> Sent: Wednesday, April 13, 2016 9:46 PM
> To: beginners at lists.squeakfoundation.org
> Subject: [Newbies] f(x, y) or Table
> 
> Greetings,
> 
> I find a lot of my data needs two indices, f(x,y) instead of one, f(x).
> 
> f(x) would be implemented easily with a Dictionary,
> 
> but how do you implement f(x,y)?
> 
> 
> I guess this is another way of asking is there a Table object or a Tuple
object,
> 
> of even a graphics object Screen that has x,y coordinates with a value?
> 
> 
> Sincerely,
> 
> Joe.
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list