On 23 Oct 2022, at 16:49, Cl��ment Dutriez <dutriezcle@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.--Dutriez Cl��mentLe dim. 23 oct. 2022 �� 13:35, Sebastian Jordan Montano <sebastian.jordan@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.ducasse@inria.fr>
> ��: "Pharo Development List" <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.ducasse@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