I forgot to mention that this also fixes a dangling space at the end of Dictionary printString.<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
<br>
On 2022-02-26T20:49:48+01:00, christoph.thiede@student.hpi.uni-potsdam.de wrote:<br>
<br>
> =============== Summary ===============<br>
> <br>
> Change Set:????????Bag printString<br>
> Date:????????????26 February 2022<br>
> Author:????????????Christoph Thiede<br>
> <br>
> This changeset customizes the Bag printString to no longer emit every occurence of each element repeatedly.<br>
> <br>
> Example:<br>
> ????{10 @ 10. 10 @ 10. 20 @ 20. 20 @ 20. 20 @ 20. 30 @ 30. 30 @ 30. 40 @ 40} asBag. 'a Bag(10 at 10->2 20 at 20->3 30 at 30->2 40 at 40->1)'.<br>
> <br>
> Thanks to Robert (rhi) for the hint!<br>
> <br>
> =============== Diff ===============<br>
> <br>
> Bag>>printElementsOn: {printing} ? ct 2/26/2022 20:26<br>
> + printElementsOn: aStream<br>
> + <br>
> + ????contents printElementsOn: aStream.<br>
> <br>
> BagTest>>testPrintString {tests} ? ct 2/26/2022 20:25<br>
> + testPrintString<br>
> + <br>
> + ????| bag |<br>
> + ????bag := Bag new.<br>
> + ????bag add: '1' withOccurrences: 5.<br>
> + ????bag add: '2' withOccurrences: 1.<br>
> + ????bag add: '3' withOccurrences: 3.<br>
> + ????<br>
> + ????self assert: 'a Bag(''1''->5 ''2''->1 ''3''->3)' equals: bag printString.<br>
> <br>
> Dictionary>>printElementsOn: {printing} ? ct 2/26/2022 20:28 (changed)<br>
> printElementsOn: aStream <br>
> ????aStream nextPut: $(.<br>
> ????self size > 100<br>
> ????????ifTrue: [aStream nextPutAll: 'size '.<br>
> ????????????self size printOn: aStream]<br>
> ????????ifFalse: [self keysInOrder<br>
> ????????????????do: [:key | aStream print: key;<br>
> ???????????????????????? nextPutAll: '->';????????????????<br>
> - ???????????????????????? print: (self at: key);<br>
> - ???????????????????????? space]].<br>
> + ???????????????????????? print: (self at: key)]<br>
> + ????????????????separatedBy: [aStream space]].<br>
> ????aStream nextPut: $)<br>
> <br>
> ---<br>
> Sent from Squeak Inbox Talk<br>
> ["Bag printString.1.cs"]<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220226/74dd8dbe/attachment.html><br>
> -------------- next part --------------<br>
> A non-text attachment was scrubbed...<br>
> Name: Bag printString.1.cs<br>
> Type: application/octet-stream<br>
> Size: 1759 bytes<br>
> Desc: not available<br>
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220226/74dd8dbe/attachment.obj><br>
> <br>