<div style="white-space:pre-wrap">the single word “first” only means one element,<br>but “prefix” can means multiple element.<br><br></div><br><div class="gmail_quote"><div dir="ltr">Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>于2016年7月27日 周三03:46写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky <<a href="mailto:nevin.brackettrozinsky@gmail.com" target="_blank">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>
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>
<br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>