March 6, 2019
1:53 p.m.
Why would that work ? What would you expect the output to be ? Try: #(1 2 3) asDictionary it fails in exactly the same way. You need key/value pairs (Associations). These do work Bag new add: #foo->100; asDictionary. Bag new addAll: 'ABABABAAAA'; valuesAndCounts.
On 6 Mar 2019, at 14:25, Tim Mackinnon <tim@testit.works> wrote:
I was surprised to find that a Bag canât convert to a dictionary - e.g.
Bag new addAll: 'aabbbbcdddâ; asDictionary
Gives an error - Dnu #key
It looks to me like Bag is inheriting a bad version of #associationsDo: and instead could simply forward it to #doWithOccurences: instead?
I know Bag is not used that much - but it comes up a lot in programming exercises.
Tim