<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        Even better! :-) <span style="font-size: 10pt;line-height: 1.5">Thanks.</span><div><span style="font-size: 10pt;line-height: 1.5"><br></span></div><div><span style="font-size: 10pt;line-height: 1.5">+1</span></div><div><span style="font-size: 10pt;line-height: 1.5"><br></span></div><div><span style="font-size: 10pt;line-height: 1.5">Best,</span></div><div><span style="font-size: 10pt;line-height: 1.5">Marcel</span></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 22.07.2019 18:52:28 schrieb Levente Uzonyi <leves@caesar.elte.hu>:</p><div style="font-family:Arial,Helvetica,sans-serif">Hi Marcel,<br><br>Dictionary >> #add: and Dictionary #associationsDo: are dangerous methods.<br>The former takes its argument and optionally integrates it into the <br>dictionary. The latter exposes the internal structure of the <br>dictionary.<br><br>Therefore, it is risky to #add: associations from one dictionary to <br>another, because the dictionaries may share these associations, and that <br>will result in hard-to-debug situations.<br><br>Here's a snippet that should just work (works without your changes, fails <br>with them):<br><br>| original copy |<br>original := Dictionary new.<br>original at: 1 put: 2.<br>copy := original collect: [ :each | each ] as: Dictionary.<br>self assert: (copy at: 1) = 2.<br>original at: 1 put: 3.<br>self assert: (copy at: 1) = 2.<br><br>And here is a snippet simulating the problem (always fails):<br><br>| original copy |<br>original := Dictionary new.<br>original at: 1 put: 2.<br>copy := Dictionary new.<br>original associationsDo: [ :each | copy add: each ].<br>self assert: (copy at: 1) = 2.<br>original at: 1 put: 3.<br>self assert: (copy at: 1) = 2<br><br>I suggest Dictionary >> #fillFrom:with: be changed to the following to <br>achieve what you want:<br><br>fillFrom: aCollection with: aBlock<br>   "Evaluate aBlock with each of aCollections's elements as the argument.<br>   Collect the resulting values into self. Answer self."<br><br>  aCollection isDictionary<br>              ifFalse: [<br>                    aCollection do: [ :element |<br>                          self add: (aBlock value: element) ] ]<br>                 ifTrue: [<br>                     aCollection associationsDo: [ :association |<br>                          self at: association key put: (aBlock value: association value) ] ]<br><br>This should also make things a bit faster in most cases. ;-)<br><br>Levente<br><br>On Mon, 22 Jul 2019, commits@source.squeak.org wrote:<br><br>> A new version of Collections was added to project The Inbox:<br>> http://source.squeak.org/inbox/Collections-mt.846.mcz<br>><br>> ==================== Summary ====================<br>><br>> Name: Collections-mt.846<br>> Author: mt<br>> Time: 22 July 2019, 3:34:37.445967 pm<br>> UUID: 32e5abfd-9153-4a57-b404-7c11380ccbd0<br>> Ancestors: Collections-mt.845<br>><br>> Here is an idea to make this work:<br>><br>> #(1 1 2 2 3 4) asSet collect: [:ea | ea -> ea] as: Dictionary<br>><br>> See inbox CollectionsTests-pre.314.mcz. Not as fast as before, though. :-)<br>><br>> =============== Diff against Collections-mt.845 ===============<br>><br>> Item was changed:<br>>  ----- Method: Collection>>fillFrom:with: (in category 'private') -----<br>>  fillFrom: aCollection with: aBlock<br>>          "Evaluate aBlock with each of aCollections's elements as the argument.<br>>       Collect the resulting values into self. Answer self."<br>> <br>> +       aCollection associationsDo: [ :each |<br>> -   aCollection do: [ :each |<br>>                 self add: (aBlock value: each) ]!<br>><br>> Item was removed:<br>> - ----- Method: Dictionary>>fillFrom:with: (in category 'private') -----<br>> - fillFrom: aCollection with: aBlock<br>> -         "Evaluate aBlock with each of aCollections's elements as the argument. <br>> -    Collect the resulting values into self. Answer self."<br>> - <br>> -     aCollection isSequenceable<br>> -              ifTrue:<br>> -                         [aCollection associationsDo:<br>> -                            [ :element | self add: (aBlock value: element)]]<br>> -                ifFalse:<br>> -                        [aCollection keysAndValuesDo:<br>> -                           [ :key :value | self at: key put: (aBlock value: value)]]!<br>><br>> Item was added:<br>> + ----- Method: Dictionary>>histogramOf: (in category 'converting') -----<br>> + histogramOf: aBlock<br>> + <br>> +       ^ self collect: [:assoc | aBlock value: assoc value] as: Bag!<br><br></div></blockquote>
                                        </div></body>