How to return array keys into another array
Andreas Raab
andreas.raab at gmx.de
Thu Jun 10 19:16:46 UTC 2004
How to return array keys into another array input := Array with: 'free' with: 'reserved' with: 'free'.
output := OrderedCollection new.
input keysAndValuesDo:[:index :value|
value = 'free' ifTrue:[output add: index].
].
^output
Cheers,
- Andreas
----- Original Message -----
From: r00tuk
To: squeak-dev at lists.squeakfoundation.org
Sent: Thursday, June 10, 2004 10:43 AM
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 array.
Thanks for your time.
Adrian
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.699 / Virus Database: 456 - Release Date: 04/06/2004
------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040610/8838a392/attachment.htm
More information about the Squeak-dev
mailing list
|