peace_the_dreamer at yahoo.com
Mon Mar 12 02:46:00 UTC 2007
In squeak we usually just leave the garbage for the
maid to pick up.
myCollection := nil.
myCollection := #() .
will clear the collection.
myCollection withAll: nil .
leaves the collection its original size and resets
On accessors versus raw IVars. its a matter of
programmer choice. If the data is hidden from other
classes it can be handled by using just the iVars
within the class w/o an accessor.
Your probably about ready for Kent Beck's book
"Smalltalk: best programming pattern practices." Which
will answer a lot of the questions you are about to
If you try to do the "simplest thing that might
possibly work." Then you would probably start with the
ivars and switch over to using accessors when there
becomes a need.
> [Newbies] Accessors
> Blake blake at kingdomrpg.com
> Mon Mar 12 01:36:12 UTC 2007 wrote:
> I've been using accessors for every instance
> and even using them
> I have to admit, because of the need to preface
> method call with
> "self", it makes the code look less clean.
> I've also ended up with what seems to be an odd
> self myCollection removeAll: self myCollection
Go reread the comment for #removeAll I believe you
will find it does not do what you wish.
One of the necessary ways to learn squeak is to try
out your ideas in a work space.
myCollection := OrderedCollection new
; add: 3
; add: 2
; add: 1
myCollection removeAll: myCollection .
and see what you get. See if you can figure out why.
Then RTFM. Read the fine manual of Kent Beck.
And RTFC. Read the fine comments (or code) in squeak
> Part of this is the self thing:
> myCollection removeAll: myCollection
> and the other part is...I guess, not being able to
> a "clear"
> Thanks for all the feedback guys. Very helpful.
> I've been too lazy with my Smalltalk (thinking) in
> past and this has
> helped a lot.
Yours in service, --Jerome Peace
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
More information about the Beginners