thanks clement.
I was looking for at: while occurrencesOf: was it. 
Now I introduced removeKey: ifAbsent: and keys because they are missing.

S

> On 23 Oct 2022, at 16:49, Clément Dutriez <dutriez...@gmail.com> wrote:
> 
> Hello Everyone,
> 
> It also makes sense to me. 
> 
> the message `addAll: aCollection`, is defined in **Collection** object. 
> The behavior of addAll: is to add every object of the collection. 
> So every dev who learn pharo will understand `addAll: aCollection` message, 
> add all object of the collection aCollection.
> If you want to count a String just send an `add:` message to Bag object. 
> 
> Finally the behavior of the Pharo Bag seems similar to Python Counter Object 
> [1].
> 
> I don't understand why you found this  behavior strange.
> 
> I hope it will help.
> 
> [1] : https://docs.python.org/3/library/collections.html#collections.Counter 
> <https://docs.python.org/3/library/collections.html#collections.Counter>
> --
> Dutriez Clément
> 
> 
> Le dim. 23 oct. 2022 à 13:35, Sebastian Jordan Montano 
> <sebastian.jor...@inria.fr <mailto:sebastian.jor...@inria.fr>> a écrit :
> For me it makes sense that in your example `aBag at: $a` returns `5`
> 
> Because as you said, a Bag is for keeping occurrences. So, at: $a should 
> return how many occurrences $a has
> 
> Sebastian
> 
> ----- Mail original -----
> > De: "Stephane Ducasse" <stephane.duca...@inria.fr 
> > <mailto:stephane.duca...@inria.fr>>
> > À: "Pharo Development List" <pharo-dev@lists.pharo.org 
> > <mailto:pharo-dev@lists.pharo.org>>
> > Envoyé: Dimanche 23 Octobre 2022 09:27:45
> > Objet: [Pharo-dev] Re: About Bag API
> 
> > it is because at: is in fact occurrencesOf:
> > 
> > S
> > 
> >> On 23 Oct 2022, at 11:26, stephane ducasse <stephane.duca...@inria.fr 
> >> <mailto:stephane.duca...@inria.fr>> wrote:
> >> 
> >> Hi
> >> 
> >> I wonder why I cannot get values of a entry using at:
> >> 
> >> | aBag |
> >> aBag := Bag new.
> >> aBag addAll: ‘aabbbacaccca’.
> >> aBag at: $a
> >>>>> 5
> >> 
> >> I have the impression that this is because Bag API never got the correct 
> >> amount
> >> of love
> >> but may be I’m wrong.
> >> 
> >> What is your opinion?
> >> 
> > > S

Reply via email to