<div dir="ltr">Hi Eliot,<div><br></div><div>Yes, because of the dual purpose of this method; 1) to ensure presence of an element and, 2) answer whether the element already existed, there isn't a clear and concise name which conveys the full nuance.  It's one of those methods which requires an initial look at the comment and/or code until one is familiar with it.</div><div><br></div><div>I considered those names, too.  I didn't care for addIfAbsent: for the reason you stated.  I don't care for ifAbsentAdd: because it's backward with other "Absent" nomenclature in the API.</div><div><br></div><div>And, I didn't go with #ifMissingAdd: because it confuses the return value with the linguistic semantics -- e.g., if it returns true, does that mean it was "absent" or that it was added?  forcing me to look at the method implementation again anyway.</div><div><br></div><div>#addNewElement: fits in with the #add... nomenclature part of the API, being like a "command" to the object, to which it may answer, "no" (false), if the element already existed.</div><div><br></div><div>It seems the only initial confusion you had was whether it signaled an Exception or not, but I see no other name that avoids the user needing to look at the implementation at least the first time.</div><div><br></div><div>Therefore, I think #addNewElement: is a good name.</div><div><br></div><div>Best,</div><div>  Chris</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 1:30 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Levente, Hi Chris,<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 14, 2017 at 1:10 PM, Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-4017367093609025822m_225119699653665851HOEnZb"><div class="m_-4017367093609025822m_225119699653665851h5">On Wed, 14 Jun 2017, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eliot Miranda uploaded a new version of Collections to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Collections-eem.756.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/trunk<wbr>/Collections-eem.756.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-eem.756<br>
Author: eem<br>
Time: 14 June 2017, 11:03:24.917631 am<br>
UUID: 8d7c03bc-1cdb-44c7-9173-10d50c<wbr>0dae29<br>
Ancestors: Collections-eem.755<br>
<br>
Add SequenceableCollection>>withou<wbr>tDuplicates for a more elegant fix to MailMessage>>to:<br>
<br>
=============== Diff against Collections-eem.755 ===============<br>
<br>
Item was added:<br>
+ ----- Method: SequenceableCollection>>withou<wbr>tDuplicates (in category 'copying') -----<br>
+ withoutDuplicates<br>
+       "Answer a copy of the receiver that preserves order but eliminates any duplicates."<br>
+       | seen |<br>
+       seen := Set new: self size.<br>
+       ^self select: [:each|<br>
+                                 (seen includes: each)<br>
+                                       ifTrue: [false]<br>
+                                       ifFalse: [seen add: each. true]]!<br>
</blockquote>
<br></div></div>
What a great opportunity to use #addNewElement::<br>
<br>
        ^self select: [ :each | seen addNewElement: each ]</blockquote><div><br></div><div>I love the functionality but I don't like the selector. It seems to imply that one must only add a new element.  So why not call this something like addIfAbsent: ?</div><div><br></div><div>Here are some suggestions.  Votes?</div><div>- don't change it; stick with addNewElement:</div><div>- addIfAbsent:</div><div>- ifAbsentAdd:</div><div>- ifMissingAdd:</div><div><br></div><div>I think I prefer ifAbsentAdd: cuz addIfAbsent: looks too much like a potential spelling error, and conflicts with typical ifAbsent: arguments supplying exception blocks.  But I could go with ifMissingAdd: because it is more distinctive.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="m_-4017367093609025822m_225119699653665851HOEnZb"><font color="#888888">Levente<br></font></span></blockquote></div><br><div class="m_-4017367093609025822m_225119699653665851gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>
</blockquote></div><br></div></div>