<div dir="ltr">Thanks Vladimir,<div><br></div><div>The correct link is this one (with the additional min/max operations in the implementation): </div><div><a href="https://github.com/luish/swift-evolution/blob/proposal-lenient-collection-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md">https://github.com/luish/swift-evolution/blob/proposal-lenient-collection-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md</a></div><div><br></div><div>Here is the pull request on the swift-evolution repo: <a href="https://github.com/apple/swift-evolution/pull/328">https://github.com/apple/swift-evolution/pull/328</a></div><div><br></div><div>Any help or suggestion to improve the proposal is welcome. :-)</div><div><br></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:small">- Luis</div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Jun 6, 2016 at 6:10 PM, Vladimir.S via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please find this draft of proposal(hope this is correct link for latest version):<br>
<a href="https://github.com/luish/swift-evolution/blob/more-lenient-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md" rel="noreferrer" target="_blank">https://github.com/luish/swift-evolution/blob/more-lenient-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md</a><br>
<br>
The main idea is to introduce 2 new subscript methods:  [clamping:] and [checking:]<br>
<br>
There was discussion in &quot;[Proposal] More lenient subscript methods over Collections&quot; and (older) &quot;[Proposal] Safer half-open range operator&quot;<div><div class="h5"><br>
<br>
On 06.06.2016 19:50, Rob Norback via swift-evolution wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi Everyone!<br>
<br>
This is my first time emailing the swift evolution list, so if this topic<br>
has already been discussed please let me know.  I looked through all the<br>
accepted and rejected proposals and it doesn&#39;t seem to be on there.<br>
<br>
The main thought is that dictionaries return optionals, so why not arrays?<br>
Or other CollectionTypes for that matter.  I would think this would be the<br>
expected behavior in this situation:<br>
<br>
var myArray:[String?] = []<br>
print(myArray[4])<br>
// EXC_BAD_INSTRUCTION, but could just be Optional(nil)<br>
<br>
Then you could do things like<br>
<br>
if let arrayValue = myArray[4] {<br>
   // do something<br>
}<br>
<br>
Of course you could simply check with with the count, but considering<br>
Swift&#39;s use of optionals to represent empty variables rather than erroring<br>
out or returning an empty String, I think this functionality would be<br>
appropriate to include in the Swift standard library.<br>
<br>
And there&#39;s about 15,000 people who&#39;ve looked for this functionality in the<br>
last year:<br>
<a href="http://stackoverflow.com/questions/25329186/safe-bounds-checked-array-lookup-in-swift-through-optional-bindings" rel="noreferrer" target="_blank">http://stackoverflow.com/questions/25329186/safe-bounds-checked-array-lookup-in-swift-through-optional-bindings</a>.<br>
<br>
Please let me know what you think.<br>
<br>
Best,<br>
Rob Norback<br>
<br>
<br></div></div>
_______________________________________________<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>
<br>
</blockquote>
_______________________________________________<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><br></div></div>