<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><div>Hi Eliot,</div><div><br></div><div>I agree with your point that methods shouldn't be more general than they need to be, but this isn't one of those cases.  SequenceableCollection already behaves like a keyed collection with #at:, #at:ifAbsent:, and #at:ifPresent:ifAbsent:.  I use them all the time, and sometimes I have an empty block for the ifAbsent:.</div><div><br></div><div>+1 for this in trunk after the 5.3 release.<br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> On Jan 19, 2020, at 3:26 PM, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
> <br>
> Christoph Thiede uploaded a new version of Collections to project The Inbox:<br>
> <a href="http://source.squeak.org/inbox/Collections-ct.872.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Collections-ct.872.mcz</a><br>
> <br>
> ==================== Summary ====================<br>
> <br>
> Name: Collections-ct.872<br>
> Author: ct<br>
> Time: 20 January 2020, 12:26:15.859545 am<br>
> UUID: 9d48e360-1121-6541-ba00-1d06311f2f0c<br>
> Ancestors: Collections-nice.870<br>
> <br>
> Implement #at:ifPresent: on SequenceableCollection<br>
> <br>
> Text theQuickBrownFox at: 42 ifPresent: [:char |<br>
>    self inform: ({char.char} joinSeparatedBy: $.) asUppercase].<br>
> <br>
> =============== Diff against Collections-nice.870 ===============<br>
> <br>
> Item was added:<br>
> + ----- Method: SequenceableCollection>>at:ifPresent: (in category 'accessing') -----<br>
> + at: index ifPresent: aBlock<br>
> + <br>
> +    ^ self at: index ifPresent: aBlock ifAbsent: []!<br>
<br>
Why is this in SequenceableCollection abd not KeyedCollection? Would it not work if implemented in Collection itself? Methods shouldn’t as general as possible. For e smoke, just because one needs a method to operate in Strings doesn’t mean it is t more useful higher up in ArrayedCollection.  Thought extended here pays dividends later on.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
> <br>
<br>
</blockquote></div></div>