[Newbies] OrderedCollection if imageMorphs

Randal L. Schwartz merlyn at stonehenge.com
Mon Nov 9 01:02:49 UTC 2009

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

Christine> Oh, I'm so so sorry - I thought it was OK to ask dumb questions on
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