<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="">Hi Ed,<div class=""><br class=""><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On May 19, 2017, at 10:10 AM, Edward Connell 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="">I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am getting the following complaint when using swap on array elements. Is this warning legitimate because of a copy on write issue? If so, is there some new swap function for array elements? I realize I can turn 1 line into 3 and do the swapping myself, it's just verbose.<div class=""><br class=""></div><div class=""><div class=""><i class="">warning: simultaneous accesses to var 'dims', but modification requires exclusive access; consider copying to a local variable</i></div><div class=""><i class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swap(&amp;dims[lastIndex], &amp;dims[lastIndex-1])</i></div></div></div></div></blockquote></div><br class=""></div></div><div class="">You can use the new swapAt() method:</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;dims.swapAt(lastIndex, lastIndex-1)</div><div class=""><br class=""></div><div class="">I recently added a Fix-It for this — but we really should also say "consider using ‘swapAt()’” in the diagnostic text as well in this case rather then mentioning copying to a local.</div><div class=""><br class=""></div><div class="">Devin</div><div class=""><br class=""></div><div class=""><br class=""></div></div></body></html>