--- a/Dictionary.st Mon Feb 06 12:55:11 2017 +0100
+++ b/Dictionary.st Mon Feb 06 12:55:22 2017 +0100
@@ -295,7 +295,6 @@
! !
-
!Dictionary methodsFor:'accessing'!
associationAt:aKey
@@ -870,11 +869,15 @@
clearContents
"remove all elements from the receiver, but do not resize.
- Returns the receiver."
+ Returns the receiver.
+ Similar to removeAll, but might behave better,
+ if the receiver is to be filled again afterwards."
keyArray atAllPut:nil.
valueArray atAllPut:nil.
tally := 0.
+
+ "Modified (comment): / 06-02-2017 / 12:54:52 / cg"
!
declare:key from:aDictionary
@@ -904,7 +907,10 @@
"declare all keys in the first argument, keys
from values taken from the second argument, aCollectionOrDictionary.
If aCollectionOrDictionary is a dictionary, access via the key;
- if it is a sequencable collection, add corresponding values pairwise."
+ if it is a sequencable collection, add corresponding values pairwise.
+ Values present in the arg will always end up in the receiver;
+ i.e. a value coming from the argument is already in the receiver,
+ the value from aDictionaryOrNil is stored into the receiver."
aCollectionOrDictionary isDictionary ifTrue:[
keys do:[:k | self at:k put:(aCollectionOrDictionary at:k) ]
@@ -931,27 +937,33 @@
d3 declareAll:#(c d) from:d2.
d3
"
+
+ "Modified (comment): / 06-02-2017 / 12:52:26 / cg"
!
declareAllFrom:aDictionaryOrNil
"merge all key-value pairs from aDictionary into the receiver.
+ Values present in the arg will always end up in the receiver;
+ i.e. a value coming from the argument is already in the receiver,
+ the value from aDictionaryOrNil is stored into the receiver.
sigh:
- For compatibility with #declare:from: the behavior should be changed as following:
- If the receiver already contains a key, the existing value is retained.
- To keep the compatibility with other smalltalks, the semantics of this remains
- as is, and #declareAllNewFrom: was added for convenience.
- See #declareAllNewFrom: which does exactly what this name implies."
+ For compatibility with #declare:from: the behavior should be changed as following:
+ If the receiver already contains a key, the existing value is retained.
+ To keep the compatibility with other smalltalks, the semantics of this remains
+ as is, and #declareAllNewFrom: was added for convenience.
+ See #declareAllNewFrom: which does exactly what this name implies."
self ~~ aDictionaryOrNil ifTrue:[
- aDictionaryOrNil notNil ifTrue:[
- aDictionaryOrNil keysAndValuesDo:[:key :value |
- self at:key put:value.
- ].
- ]
+ aDictionaryOrNil notNil ifTrue:[
+ aDictionaryOrNil keysAndValuesDo:[:key :value |
+ self at:key put:value.
+ ].
+ ]
]
"Modified: / 18-09-2006 / 22:01:12 / cg"
+ "Modified (comment): / 06-02-2017 / 12:51:51 / cg"
!
declareAllNewFrom:aDictionaryOrNil