How to return array keys into another array

Jarvis, Robert P. (Bob) (Contingent) bob.jarvis at
Thu Jun 10 18:26:16 UTC 2004

a := Array with: 'free' with: 'reserved' with: 'free' with: 'reserved'.
a2 := ((1 to: a size) inject: OrderedCollection new into: [ :oc :i | (a at:
i) = 'free' ifTrue: [ oc add: i ]. oc ]) asArray.

Bob Jarvis
Compuware @ Timken 

-----Original Message-----
From: r00tuk [mailto:r00tuk at]
Sent: Thursday, June 10, 2004 1:43 PM
To: squeak-dev at
Subject: How to return array keys into another array

Hello All 
I am quite new to smalltalk and am hoping someone can help me or point me in
the right direction as I am quite stumped by this.
I have an array with elements either being 'free' or 'reserved'.  I am
trying to get only the keys for all the element that match 'free' into a new
Thanks for your time. 

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.699 / Virus Database: 456 - Release Date: 04/06/2004

PLEASE NOTE: The above email address has recently changed from a previous naming standard -- if this does not match your records, please update them to use this new name in future email addressed to this individual.

This message and any attachments are intended for the 
individual or entity named above. If you are not the intended
recipient, please do not forward, copy, print, use or disclose this 
communication to others; also please notify the sender by 
replying to this message, and then delete it from your system. 

The Timken Company

More information about the Squeak-dev mailing list