[swift-users] The nil coalescing operator
jordan_rose at apple.com
Tue Feb 23 11:09:29 CST 2016
That does seem like a bug, but one possibility is that 'result' has type 'AnyObject', and so you're getting an extra level of optional due to the subscript operator possibly not being there. Do you have a full, self-contained test case?
> On Feb 22, 2016, at 15:17 , Valentin Radu via swift-users <swift-users at swift.org> wrote:
> 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 184.108.40.206 ? 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?
> – V
> swift-users mailing list
> swift-users at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users