[Cuis-dev] Some more Bag tweaks

Juan Vuletich JuanVuletich at zoho.com
Sat May 14 08:44:12 PDT 2022


On 5/14/2022 6:21 AM, Luciano Notarfrancesco via Cuis-dev wrote:
> I added a comment with a warning about reproducibility to 
> Collection>>#atRandom:, Set>>#atRandom: and Bag>>#atRandom:. I also 
> moved the empty check to the top of the methods in 
> Collection>>#atRandom: and Bag>>#atRandom:, the idea behind this is 
> that '0 atRandom: aGenerator' produces a different error, and doing 
> 'self emptyCheck' first is better because if at some point we change 
> Collection>>#errorEmptyCollection to signal a new exception like say 
> EmptyCollectionException we won't need to change these methods. 
> Finally the last line in those two methods should never be executed, 
> unless the collection is broken (i.e. size returns n, but do: iterates 
> over less than n elements), so I just do "self error: 'collection 
> invariants broken'"
>
> Let me know if you have any more suggestions, I really want the kernel 
> classes to be absolutely perfect.
>
> Thanks!!
> Luciano
>

At GitHub now. Thanks a lot!

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
https://independent.academia.edu/JuanVuletich
https://www.researchgate.net/profile/Juan-Vuletich
https://patents.justia.com/inventor/juan-manuel-vuletich
https://twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220514/781fea51/attachment.htm>


More information about the Cuis-dev mailing list