<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=""><blockquote type="cite" class="">On Dec 24, 2015, at 1:11 AM, Árpád Goretity &lt;<a href="mailto:arpad.goretity@gmail.com" class="">arpad.goretity@gmail.com</a>&gt; wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12.8px;" class="">&gt; The comments in the generated header for UnsafeMutablePointer claim that its regular init() method constructs a null pointer.</span><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-size: 12.8px;" class=""><br class=""></span></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-size: 12.8px;" class="">That's right, and I have tried it as well. Yet, type inference doesn't like like it, and I get back an error similar to what I have already described, but this time with inout and UnsafeMutablePointer:</span></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-size: 12.8px;" class=""><br class=""></span></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-size: 12.8px;" class="">&nbsp; &nbsp;&nbsp;</span>result values in '? :' expression have mismatching types 'inout T' and 'UnsafeMutablePointer&lt;T&gt;'</div></div></blockquote></div><div class=""><br class=""></div><div class="">That’s because you’re putting it in a ternary expression. Swift has magic to automatically turn inout arguments (which is what you get when you put a &amp; in front of an argument) into Unsafe(Mutable)Pointers if that’s what a function asks for. However, you’re not getting to that point, because you’re putting an inout argument and an UnsafeMutablePointer on opposite sides of the ternary operator. That won’t work, because the ternary operator requires both objects to be of the same type, and since your inout argument hasn’t been sent to the function yet, it hasn’t been automagically translated into a pointer.</div><div class=""><br class=""></div><div class="">What Félix said is also true; you can’t trust that &amp;array[0] will get you a pointer to the array’s internal storage. It’s better to use .withUnsafeMutableBufferPointer for that.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>