<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Ahhh, right.<div class=""><br class=""><div class="">I believe the thinking here is that since this is an avoidable error, it should be handled in the client code with an `if !array.isEmpty { … }`), leaving errors to really exceptional and unexpected conditions.</div><div class="">Using optional here will serve the same purpose, IMHO, but instead of preventing the condition, one would have to react to the consequences later. Moreover the type will now be Optional<Element> and it would also be really tempting to write something like `array.removeFirst()!` and have the same trapping behavior.</div><div class=""><br class=""></div><div class="">Dave, Dmitri, please correct me if I’m wrong.</div><div class=""><br class=""></div><div class="">max</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 6, 2016, at 10:34 AM, James Campbell <<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">What I mean't is it would be great is if it was a native swift error :) so we could use try? syntax.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jan 6, 2016 at 6:32 PM, Max Moiseev <span dir="ltr" class=""><<a href="mailto:moiseev@apple.com" target="_blank" class="">moiseev@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi James,<div class=""><br class=""></div><div class="">I believe <a href="https://github.com/apple/swift/blob/master/stdlib/public/core/RangeReplaceableCollectionType.swift#L235" target="_blank" class="">this code</a> already handles empty array scenario by failing if the precondition is not met.</div><div class="">Or do you have something else in mind?</div><div class=""><br class=""></div><div class="">max</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Jan 6, 2016, at 9:36 AM, James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div dir="ltr" class="">If you call removeFirst and the array is empty it would be great if it was optional so it could return nil or at least it threw an error so you could handle that case.<br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size:16px;line-height:19.2px" class=""></span><span style="font-size:12.8px" class=""> Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class=""><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank" class="">+44 7523 279 698</a></div></div></div></div></div></div>
</div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZdiBPeKLcE1ZkxjSogRct0bur3WJrrZggvfZYd5wkdIp5FK734JzyuHDaQTKyyfFUl4Oetpv6m-2BbZl9vCejfAtdKcEccAHavkeM-2FQ-2BGNbCj3zofZsTXWHdFNOT5ZSWyTgcU3aa6-2FXHdaIJGJa5eDVO6RIWnNE39ULsgVA13-2FQQQ5yg-2F8NG99YRPYv-2FH0X00Ji86j38e11VyPJKC9ohGYRHhByX5bowmORio6Ge02ooM-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size:16px;line-height:19.2px" class=""></span><span style="font-size:12.8px" class=""> Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class="">+44 7523 279 698</div></div></div></div></div></div>
</div>
</div></blockquote></div><br class=""></div></div></body></html>