<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">* We considered using `first` and `last` as the basis for both<br> single-element and multiple-element operations (such that `prefix(3)`<br> would become `first(3)`, etc.), but:<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> 1. These seemed like distinct functionalities, particularly since<br> their types are different.</blockquote><div><br></div><div>I think the functionality of “Please give me the first 1 element” is extremely similar to “Please give me the first n elements”.</div><div><br></div><div> </div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Keeping those issues in mind, do you still prefer `first(n)` over `prefix(n)`?</blockquote><div class="gmail_extra"><br></div><div class="gmail_extra">In my subjective opinion, `.first`, `.first(n)`, and `starts(with: [1, 2, 3])` are crystal-clear at the use site, and coexist just fine. Additionally, `hasPrefix([1, 2, 3])` is equally clear and I would be fine with that—in particular I am fine with the “get” and “test” methods using different words.</div><div class="gmail_extra"><br></div><div class="gmail_extra">By contrast, I find `prefix(n)` to be unclear about the role of `n`. Something like `prefix(limit: n)` </div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 26, 2016 at 3:46 PM, Brent Royal-Gordon <span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">> On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky <<a href="mailto:nevin.brackettrozinsky@gmail.com">nevin.brackettrozinsky@gmail.com</a>> wrote:<br>
><br>
> However, I believe that `first(n)` and `last(n)` read more clearly at the point of use than `prefix(n)` and `suffix(n)`.<br>
<br>
</span>I've seen this a couple of times. It's something I bring up in "Other alternatives":<br>
<br>
> * We considered using `first` and `last` as the basis for both<br>
> single-element and multiple-element operations (such that `prefix(3)`<br>
> would become `first(3)`, etc.), but:<br>
><br>
> 1. These seemed like distinct functionalities, particularly since<br>
> their types are different.<br>
><br>
> 2. We're not comfortable with heavily overloading a property with a<br>
> bunch of methods, and didn't want to make `first` and `last` into<br>
> methods.<br>
><br>
> 3. Most APIs work fine, but `hasFirst(_:)` is atrocious, and we see<br>
> no better alternative which includes the word `first`.<br>
<br>
To give you an idea of what I mean by #3:<br>
<br>
if numbers.hasFirst([1, 2, 3, 4, 5]) && numbers.hasLast([5, 4, 3, 2, 1]) { … }<br>
<br>
Keeping those issues in mind, do you still prefer `first(n)` over `prefix(n)`?<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
</font></span></blockquote></div><br></div></div>