unique values in collections
Scott Wallace
scott.wallace at squeakland.org
Thu Mar 13 18:14:09 UTC 2003
Hi, Janet,
Use a Set, not of the *amounts* (two different accounts might by
coincidence have the same amounts) but of the *accounts*.
Thus, consider something like:
allAccounts := Set new.
portfolios do: [:aPortfolio | allAccounts addAll: aPortfolio accounts].
total := (allAccounts collect: [:anAccount | anAccount amount]) sum.
Cheers,
-- Scott
At 11:26 PM -0800 3/12/03, Janet Abdul-Karim wrote:
>I have a collection of portfolios and each portfolio has a
>collection of accounts. I am trying to get the sum of the accounts,
>but my problem is if that some portfolios have the same account then
>that would not give me the write sum. is there some method to make
>sure all value are unique in a collection
More information about the Squeak-dev
mailing list
|