<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="">Just to add further salt, (or perhaps more appropriately, sugar) to optional chaining, it's not just map, it’s also flatMap, as and when required. Here’s a very silly example demonstrating it:<div class=""><br class=""></div><div class=""><div class="">enum Hat { case Cap, Stetson, Helmet }</div><div class=""><br class=""></div><div class="">struct Pet { let age: Int, hat: Hat? } // a pet might wear a hat?!</div><div class=""><br class=""></div><div class="">struct Person { let name: String, pet: Pet? }</div><div class=""><br class=""></div><div class="">let p = Person(name: "Burt", pet: Pet(age: 10, hat: .Stetson))</div><div class=""><br class=""></div><div class="">(p.pet?.hat).dynamicType // Optional<Hat>.Type</div><div class="">p.pet.map { $0.hat }.dynamicType // Optional<Optional<Hat>>.Type</div><div class="">p.pet.flatMap { $0.hat }.dynamicType // Optional<Hat>.Type</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">This topic is going somewhat off-piste, so I’ll stop now!</div><div class=""><br class=""></div><div class="">Al</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Dec 2015, at 18:40, <a href="mailto:thorsten@portableinnovations.de" class="">thorsten@portableinnovations.de</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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; float: none; display: inline !important;" class="">Interesting stuff indeed!</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">Am 10.12.2015 um 19:21 schrieb Al Skipp <<a href="mailto:al_skipp@fastmail.fm" class="">al_skipp@fastmail.fm</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Interesting stuff!</div><div class=""><br class=""></div><div class="">It did confuse me too, as I was expecting your initial code sample to work. My understanding is that ‘?’ is syntactic sugar for ‘map’ in this context. Anything following the ‘?’ is inside the Optional context.</div></div></div></blockquote><div class=""><br class=""></div><div class="">That is a great insight! Of course, ?. is map! That does make sense! And using parentheses to mark the end of the Optional context introduced by ?. makes sense, too.</div><div class=""><br class=""></div><div class="">Thanks, Greg and Al!</div><div class=""><br class=""></div><div class="">-Thorsten</div></div></div></div></blockquote></div><br class=""></div></div></body></html>