<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="">When I try to observe a key path that includes an optional (“<span style="background-color: rgb(255, 255, 255);" class="">controller” in this case)</span>&nbsp;in Swift, I get a compiler error saying ‘Type of expression is ambiguous without more context’ on the backslash in this statement:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;submodelObservation = observe(<span style="text-decoration: underline" class="">\</span>.controller.submodel) { object, change <span style="color: #ba2da2" class="">in</span></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">&nbsp; &nbsp;&nbsp;</span>// code</div></blockquote><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: #ba2da2" class="">@objc</span> <span style="color: #ba2da2" class="">dynamic</span> <span style="color: #ba2da2" class="">internal</span> <span style="color: #ba2da2" class="">var</span> controller: <span style="color: #4f8187" class="">Controller</span>?</div></div><div class=""><br class=""></div><div class="">in the the “Controller" class:</div><div class=""><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">&nbsp; &nbsp;&nbsp;</span>@objc<span style="color: #000000" class=""> </span>dynamic<span style="color: #000000" class=""> </span>internal<span style="color: #000000" class=""> </span>var<span style="color: #000000" class=""> submodel: </span><span style="color: #4f8187" class="">SubmodelForImporting</span><span style="color: #000000" class="">?</span></div></div><div class=""><span style="color: #000000" class=""><br class=""></span></div><div class=""><br class=""></div>I’m not clear why this would be, but I admit I missed the discussion the first time it happened. If I make “Controller” non-optional the code compiles fine.<div class=""><br class=""></div><div class="">Certainly with traditional KVO you can observe key paths that have ‘nil’ values in them! Is this something stupid I’m doing, a compiler bug, or a design decision? I’m asking here because if it’s a design decision I’d like to appeal it, certainly.</div><div class=""><br class=""></div><div class="">-Wil</div></body></html>