Storing and Retrieving Point
Aaron J Reichow
reic0024 at d.umn.edu
Thu Sep 27 20:58:24 UTC 2001
On Thu, 27 Sep 2001, Ken G. Brown wrote:
> I'm having trouble storing and retrieving Points. What am I doing wrong?
>
> pt _ Point new.
> pt _ 25 at 125.
> dict _ Dictionary new.
> dict at: 'first' put: #('text' pt).
> readPt _ ((dict at: 'first') at: 2). "readPt is now a Symbol"
readPt is now a symbol because it was stored as a symbol in #('text' pt).
What the #() array literal does is store things as symbols (hence the #)
unless the the element is a literal itself (e.g., numbers, strings). To
get it to be stored as you expected, try this:
from:
> dict at: 'first' put: #('text' pt).
to:
> dict at: 'first' put: {'text' . pt}.
-- or --
> dict at: 'first' put: Array with: 'text' with: pt.
Regards,
Aaron
Aaron Reichow :: UMD ACM Pres :: http://www.d.umn.edu/~reic0024/
"A weed is just a plant whose virtures have not
yet been discovered." :: r. w. emerson
More information about the Squeak-dev
mailing list
|