<div dir="ltr">It might have something to do with
<p class="p1"><span class="s1">`setSubscriptee`</span></p><p class="p1"><span class="s1">with seems from the implementation is a `mutating` operation.</span></p><p class="p1"><span class="s1">If you comment it out, or just give it a empty callback, it will pass compile.</span></p><p class="p1"><span class="s1"><br></span></p><p class="p1"><span class="s1">Kyle</span></p></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Mar 22, 2016 at 6:23 AM Howard Lovatt via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div><br></div><div>I don't understand your comment, can you explain some more please?</div><div><br></div><div>Thanks,</div><div><br></div><div> -- Howard. </div><div><span></span><br><br>On Monday, 21 March 2016, zh ao <<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">You protocol is not defined properly.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 21, 2016 at 7:08 AM, Howard Lovatt via swift-users <span dir="ltr"><<a>swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">HI,<div><br></div><div>Does anyone know what is happening here:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><p>protocol Subscriptable {</p></div><div><p> associatedtype Element</p></div><div><p> associatedtype Index</p></div><div><p> var firstIndex: Index { get }</p></div><div><p> var lastIndex: Index { get }</p></div><div><p> subscript(index: Index) -> Element { get set }</p></div><div><p>}</p></div><div><p><br></p></div><div><p>struct AllSubscriptable<E, I>: Subscriptable {</p></div><div><p> typealias Element = E</p></div><div><p> typealias Index = I</p></div><div><p> let firstIndexee: () -> I</p></div><div><p> let lastIndexee: () -> I</p></div><div><p> let subscriptee: (index: I) -> E</p></div><div><p> let setSubscriptee: (index: I, element: E) -> Void</p></div><div><p> var firstIndex: I { return firstIndexee() }</p></div><div><p> var lastIndex: I { return lastIndexee() }</p></div><div><p> subscript(index: I) -> E {</p></div><div><p> get { return subscriptee(index: index) }</p></div><div><p> set { setSubscriptee(index: index, element: newValue) }</p></div><div><p> }</p></div><div><p>}</p></div><div><p><br></p></div><div><p>extension Array {</p></div><div><p> var asScriptable: AllSubscriptable<Element, Int> {</p></div><div><p> return AllSubscriptable(</p></div><div><p> firstIndexee: { return self.startIndex }, // Error: Cannot convert `() -> Int` to expected `() -> _`</p></div><div><p> lastIndexee: { return self.endIndex },<br></p></div><div><p> subscriptee: { return self[$0] },</p></div><div><p> setSubscriptee: { self[$0] = $1 }</p></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><p> )</p></div><div><p> }</p></div><div><p>} </p><p><br></p></div></blockquote>The error, "Cannot convert `() -> Int` to expected `() -> _`", on the `firstIndexee` closure is very strange since the types are correct and the same as `lastIndexee` which does not have an error. <div><br></div><div>Also if the set subscript in Subscriptable and then all the other set support in AnySubscriptabe and in the extension is removed, then no error.</div><div><br></div><div>Any clues to why?<span><font color="#888888"><br><div><br></div><div>-- Howard.<br></div></font></span></div></div>
<br>_______________________________________________<br>
swift-users mailing list<br>
<a>swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>
</blockquote></div><div></div><br><br>-- <br>-- Howard.<br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div>