How to return array keys into another array

Travis Griggs tgriggs at
Mon Jun 14 16:55:10 UTC 2004

adrian voss wrote:
> 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 array.
> Thanks for your time.

yourArray keys select: [:i | (yourArray at: i) isFree]

isFree is assumed to be whatever test you use to determine matches for 

Being able to ask yourArray for keys is an extension I make in 
VisualWorks (see 
I don't know if the same extension exists for Squeak already or not.

Travis Griggs
Key Technology
Achille's Heel?!?! What about "Goliath's Forehead"

DISCLAIMER: This email is bound by the terms and conditions described at

More information about the Squeak-dev mailing list