Philosophical questions about collections
Diego Gomez Deck
DiegoGomezDeck at ConsultAr.com
Sun Jul 1 16:57:30 UTC 2001
I can 'fix/complete' the Collection tree, but I'd like to know the
community thinking....
My idea is that #= answer with true when the two collection have the same
specie, the same contents, the same order, the same keys and the same
occurrences.
We need some extras messages to handle the other ways to compare collection:
#sameContent: ignores the specie, ignores the order, ignores the keys and
ignores the occurrences.
#exactContent: ignores the specie, ignores the order, ignores the keys
but care of the occurrences.
#sameKeys: the two collection has the same Set of keys, don't care
about the specie.
Some examples:
| a d d2 b |
a := {1. 2. 3}.
d := Dictionary new.
d at:'someKey' put:1.
d at:'otherKey' put:2.
d at:'justOtherKey' put:3.
b add:1.
b add:1.
b add:2.
b add:3.
a sameContent: d -> true
a sameContent: b -> true
a exactContent: d -> true
a exactContent: b -> false
d2 := Dictionary new.
d2 at:1 put:1.
d2 at:2 put:2.
d2 at:3 put:3.
d2 sameKeys:a -> true "the array has integer keys"
What do you think about this??
TIA,
Diego Gomez Deck
> > For example, Dictionary use Set>>= that ignores keys.
>
>This looks like an accident, to me.
>
>
>Lex
More information about the Squeak-dev
mailing list
|