<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Louis,</div><div class=""><br class=""></div>I believe the difference is due to the performance guarantees. One can only efficiently implement `popFirst` and `removeFirst` on slices, where it’s just a matter of index manipulation. Removing the first element of a Collection is potentially an O(n) operation. Using `popFirst` in a loop in some algorithm would result in a quadratic complexity.<div class=""><br class=""></div><div class="">So the reason is: we only provide `popFirst` in a context where it is guaranteed to be O(1). Same applies to `popLast`, actually.. I think.<div class=""><br class="">To reiterate what I mentioned in <a href="https://github.com/apple/swift/pull/5333" class="">your pull request</a>:<div class=""><blockquote type="cite" class="">This case clearly identifies the flaw in the design of these methods, solving which might become a part of a follow-up to <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0132-sequence-end-ops.md" class="">this proposal </a>one day.<br class=""></blockquote><div class=""><br class=""></div>Max<br class=""><br class=""><blockquote type="cite" class="">On Oct 18, 2016, at 11:16 AM, Louis D'hauwe via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Collections have mutating functions for removing the first and last element.<br class="">One of these is popLast(), which will safely check if the collection is empty before popping the last element.<br class=""><br class="">So calling popLast() is like doing:<br class="">if !collection.isEmpty {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>collection.removeLast()<br class="">}<br class=""><br class="">There also exists a popFirst() function, but what I find inconsistent is that popFirst() is only available on ArraySlice.<br class=""><br class="">Example:<br class="">var collection = [1, 2, 3, 4]<br class="">collection.removeFirst() // works fine<br class="">collection.removeLast() // works fine<br class="">let last = collection.popLast() // works fine<br class="">let first = collection.popFirst() // Compile error: [Int] is not convertible to 'ArraySlice<Int>'<br class=""><br class="">Is it intended that popLast() is available on collections, but popFirst() is not?<br class=""><br class="">– Louis D'hauwe<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class=""></div></div></div></body></html>