Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bag improvements #2773

Ducasse opened this Issue Mar 7, 2019 · 0 comments


1 participant
Copy link

Ducasse commented Mar 7, 2019

From the mailing-list discussions.
Tim published a related issue. #2763
So we should sync and add also more tests.

Handling as: Dictionary
is really quite straightforward.
Add a one-line method to Bag:

associationsDo: aBlock
contents associationsDo: aBlock.

This is a good idea anyway, because currently there is a bug where
aBag associationsDo: aBlock
fails to pass Associations to aBlock. Once you have done that,
'abracadabra' asBag as: Dictionary
just works. This one simple addition

  • makes aBag associationsDo: aBlock work when it didn't before
  • makes aBag asDictionary work
  • makes aBag as: Dictionary work
  • makes Dictionary newFrom: aBag work

#valuesAndCounts is a method that violates good OO practice,
because it exposes (what you'd expect to be) private state.
For example,
b := 'abracadabra' asBag.
b valuesAndCounts at: $a put: 'BOOM!'.
select, Print It, BOOM!. It should copy the dictionary.

@MarcusDenker MarcusDenker added this to To do in Collections Mar 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.