<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">You can’t pass a `let` as an `inout` argument. I’d guess that’s what’s happening is the `arr[2]` part is creating a temporary var to which the `&amp;` part then provides a reference. `b` is then dutifully modified in the function, but there’s no mechanism for copying it back into `arr` when `foo` returns, so the change isn’t reflected at the call site.<div class=""><br class=""></div><div class="">I *think* that the documentation you’re referring to in your last sentence is talking about when the value is updated at the call site. That is, `arr` itself isn’t updated until `foo` returns, but <i class="">within</i> `foo`, the argument `a` would have whatever value you assign it, whenever you assign it.</div><div class=""><br class=""></div><div class="">I think.</div><div class=""><br class=""></div><div class="">HTH (also, I hope I’m right… the only thing worse that no info is bad info)</div><div class="">- Dave Sweeris</div><div class=""><br class=""><blockquote type="cite" class="">On Jun 11, 2016, at 12:29 PM, Karl Pickett via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">I don't believe the (spartan) docs address this case:<br class=""><br class="">func foo(inout a: [Int], inout b: Int) {<br class="">&nbsp; &nbsp;let acopy = a<br class="">&nbsp; &nbsp;a = [4, 5, 6]<br class="">&nbsp; &nbsp;print(acopy) &nbsp;// prints "[1, 2, 3]"<br class="">&nbsp; &nbsp;b = 99<br class="">&nbsp; &nbsp;print(a) &nbsp; // prints "[4, 5, 6]"<br class="">&nbsp; &nbsp;print(acopy) &nbsp;// prints "[1, 2, 99]" (e.g. a let variable changed!)<br class="">}<br class=""><br class="">var arr = [1,2,3]<br class=""><br class="">foo(&amp;arr, b: &amp;arr[2])<br class=""><br class="">print(arr) &nbsp;// prints "[4, 5, 6]"<br class=""><br class=""><br class="">Is this code "undefined", meaning the spec / doc doesn't specifically<br class="">say what should be happening? &nbsp;For instance, I can't believe a let<br class="">variable gets changed. &nbsp;The docs also say inout changes the original<br class="">value when the function ends, not in the middle as is happening here.<br class="">_______________________________________________<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=""></blockquote><br class=""></div></body></html>