<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=""><div class="">Not sure why it is happening, but given below are my observations:</div><div class=""><br class=""></div><div class=""><b class="">Simplified version:</b></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">var</span> array = [<span style="color: #272ad8" class="">1</span>, <span style="color: #272ad8" class="">2</span>, <span style="color: #272ad8" class="">3</span>, <span style="color: #272ad8" class="">4</span>, <span style="color: #272ad8" class="">5</span>]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">_</span><span style="color: #000000" class=""> = </span><span style="color: #4f8187" class="">array</span><span style="color: #000000" class="">.popFirst() </span>//error: cannot use mutating member on immutable value: 'array' is immutable</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">_</span><span style="color: #000000" class=""> = </span><span style="color: #4f8187" class="">array</span><span style="color: #000000" class="">.</span><span style="color: #3e1e81" class="">popLast</span><span style="color: #000000" class="">() </span>//works ok</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><font color="#0433ff" class="">popFirst</font> is not available in the <font color="#0433ff" class="">Array</font> documentation and “<font color="#0433ff" class="">Jump to Definition</font>” doesn’t seem to work.</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class="">Thanks and regards,</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class="">Muthu</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 14 Sep 2017, at 9:59 AM, Jon Shier via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>I think there’s something strange with popFirst. It doesn’t show up in the autocomplete in Xcode, but it compiles, and popLast doesn’t throw the same error. removeFirst doesn’t either, though it’s unsafe. Weird.<div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Jon</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 13, 2017, at 9:47 PM, Zhao Xin via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">I begin to think it is related to how you `<span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">popFirst(</span><wbr style="font-family:arial,sans-serif;font-size:12.800000190734863px" class=""><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">)` implemented. Check it or post it here.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class=""><br class=""></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">Zhao Xin</span></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Sep 14, 2017 at 9:36 AM, Roderick Mann <span dir="ltr" class="">&lt;<a href="mailto:rmann@latencyzero.com" target="_blank" class="">rmann@latencyzero.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yeah, that's not it. I made the change you suggested, I get the same error.<br class="">
<span class="im HOEnZb"><br class="">
&gt; On Sep 13, 2017, at 18:11 , Zhao Xin &lt;<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
</span><div class="HOEnZb"><div class="h5">&gt; Change `self` to `ModelFetcher`. You are calling a class static property, not a class instance property.<br class="">
&gt;<br class="">
&gt; Zhao Xin<br class="">
&gt;<br class="">
&gt; On Thu, Sep 14, 2017 at 8:37 AM, Rick Mann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt; Moving to Swift 4, I'm running into an issue for which I can't seem to find an answer in google:<br class="">
&gt;<br class="">
&gt; "Cannot use mutating member on immutable value: 'self' is immutable"<br class="">
&gt;<br class="">
&gt; The code looks like:<br class="">
&gt;<br class="">
&gt; class<br class="">
&gt; ModelFetcher : NSObject, URLSessionDelegate<br class="">
&gt; {<br class="">
&gt;&nbsp; &nbsp; &nbsp;...<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; let&nbsp; &nbsp; &nbsp;managerDispatchQueue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&nbsp; &nbsp;DispatchQueue(label: "Model Download Manager Queue")<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; var&nbsp; &nbsp; &nbsp;pendingFetchers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&nbsp; &nbsp;[ModelFetcher]()<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; var&nbsp; &nbsp; &nbsp;currentFetcher:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModelFetcher?<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp;class<br class="">
&gt;&nbsp; &nbsp; &nbsp;func<br class="">
&gt;&nbsp; &nbsp; &nbsp;startNextFetcher()<br class="">
&gt;&nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.managerDispatchQueue.<wbr class="">async<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;guard<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.currentFetcher == nil,<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let mf = self.pendingFetchers.popFirst(<wbr class="">)<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ~~~~ ^&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error: cannot use mutating member on immutable value: 'self' is immutable<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.currentFetcher = mf<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mf.start()<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br class="">
&gt;&nbsp; &nbsp; &nbsp;}<br class="">
&gt;&nbsp; &nbsp; &nbsp;...<br class="">
&gt; }<br class="">
&gt;<br class="">
&gt; This code compiled fine in Xcode 8, or in Xcode 9/Swift 3.2 as a monolithic app (the error shows up when this code is factored into a framework). Other mutating references to self seem to compile okay (e.g. "self.currentFetcher = nil" or "self.pendingFetchers.remove(<wbr class="">at: idx)"). Not sure what's special about this one.<br class="">
&gt;<br class="">
&gt;<br class="">
&gt; --<br class="">
&gt; Rick Mann<br class="">
&gt; <a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class="">
&gt;<br class="">
&gt;<br class="">
&gt; ______________________________<wbr class="">_________________<br class="">
&gt; swift-users mailing list<br class="">
&gt; <a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
&gt;<br class="">
<br class="">
<br class="">
</div></div><span class="HOEnZb"><font color="#888888" class="">--<br class="">
Rick Mann<br class="">
<a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class="">
<br class="">
<br class="">
</font></span></blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>