[Newbies] OrderedCollection if imageMorphs

Christine Wolfe cwdw01 at earthlink.net
Mon Nov 9 01:08:07 UTC 2009

Oh wow! thanks - having the sample code will be a huge help.  I'll give it a

-----Original Message-----
From: Randal L. Schwartz [mailto:merlyn at stonehenge.com] 
Sent: Sunday, November 08, 2009 8:03 PM
To: Christine Wolfe
Cc: beginners at lists.squeakfoundation.org
Subject: Re: [Newbies] OrderedCollection if imageMorphs

>>>>> "Christine" == Christine Wolfe <cwdw01 at earthlink.net> writes:

Christine> Oh, I'm so so sorry - I thought it was OK to ask dumb questions
Christine> the newbie forum (blush) I'll try to figure out how to make an
Christine> instance variable an order collection.

It's perfectly OK, and that's why you were corrected. :)

Basically, you'll do the following:

* add an instance variable: contents

on your instance side, add:

      super initialize.
      contents := OrderedCollection new.

then for each item of the collection protocol, delegate it, as in:

    add: anItem
      ^contents add: anItem.

    includes: anItem
      ^contents includes: anItem.

      ^contents size.

and so on.  If you get really tired of adding all of them,
just add them as you need them (when the debugger tells you :).

If you wanna get really tricky, you can add a #doesNotUnderstand: handler to
perform the method on the contents variable, but that can mess up your
debugging, so it's better if you don't.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

More information about the Beginners mailing list