<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 &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;于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">&gt; On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky &lt;<a href="mailto:nevin.brackettrozinsky@gmail.com" target="_blank">nevin.brackettrozinsky@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; 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&#39;ve seen this a couple of times. It&#39;s something I bring up in &quot;Other alternatives&quot;:<br>
<br>
&gt; * We considered using `first` and `last` as the basis for both<br>
&gt;   single-element and multiple-element operations (such that `prefix(3)`<br>
&gt;   would become `first(3)`, etc.), but:<br>
&gt;<br>
&gt;   1. These seemed like distinct functionalities, particularly since<br>
&gt;      their types are different.<br>
&gt;<br>
&gt;   2. We&#39;re not comfortable with heavily overloading a property with a<br>
&gt;      bunch of methods, and didn&#39;t want to make `first` and `last` into<br>
&gt;        methods.<br>
&gt;<br>
&gt;   3. Most APIs work fine, but `hasFirst(_:)` is atrocious, and we see<br>
&gt;      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]) &amp;&amp; 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>