[swift-users] The nil coalescing operator

Valentin Radu radu.v.valentin at icloud.com
Mon Feb 22 17:17:15 CST 2016


Hello all,


I have a question re the nil coalescing operator. Shouldn’t 

print ("This machine's ip is \(result["ip"] ?? “unknown")”) 

return This machine's ip is 78.97.202.31 ? Since the value is always String, not String?.  However, it still surrounds the ip with Optional(). 

So I’m using, (result.0["ip"] ?? "nil").description but is long and dirty. Any thoughts? 

Cheers!
– V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160223/70e51942/attachment.html>


More information about the swift-users mailing list