How to return array keys into another array

Doug Way dway at
Mon Jun 14 17:42:28 UTC 2004

Travis Griggs wrote:

> yourArray keys select: [:i | (yourArray at: i) isFree]
> isFree is assumed to be whatever test you use to determine matches for 
> 'free'.
> 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.

No, this extension doesn't exist in Squeak right now.  (Which is why I 
was confused when Ned also suggested this. :-) )

I usually think of these Array numbers as "indices", not "keys", but I 
guess "keys" is not unreasonable... it lets you treat the array more 
like a dictionary.

- Doug

More information about the Squeak-dev mailing list