<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><blockquote type="cite" class=""><div class="">On Jan 19, 2016, at 7:08 AM, Craig Cruden via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">i.e. the Swift way of doing things that comes to mind (equivalent) would be:<div class=""><br class=""></div><div class="">let host: String? = “host”</div><div class="">let port: Int? = “80”</div><div class=""><br class=""></div><div class="">let inetAddress = InetSocketAddress?</div><div class="">if let host = host, port = port {</div><div class=""> inetAddress = InetSocketAddress(host, port)</div><div class="">}</div><div class="">else {</div><div class=""> inetAddress = nil</div><div class="">}</div><div class=""><br class=""></div><div class="">Just wondering if there was a cleaner way - because to me that just looks ugly.</div></div></div></blockquote><br class=""></div><div>You can always wrap it in a (nicely inline-able) function for cleanliness:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div>func makeAddr(host: String?, port: Int?) -> InetSocketAddress? {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>guard let h = host, p = port else { return nil }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return InetSocketAddress(host: h, port: p)</div><div>}</div><div><br class=""></div><div>// … somewhere else …</div><div>let host: String? = getHost()</div><div>let port: Int? = getPort()</div><div><br class=""></div><div>guard let inetAddress = makeAddr(host, port) else { throw SocketError(EADDR) }</div></blockquote><br class=""><div class="">Cheers,</div><div class="">-Jim</div></body></html>