[swift-evolution] Suppress unused result warnings on try? if attempted statement does not return

Brent Royal-Gordon brent at architechies.com
Fri Jun 17 06:20:09 CDT 2016


> The required _ = try? on what used to be a BOOL result in ObjC is incredibly annoying, mostly with NSXML* classes on OS X where you really don't care about the error 99% of the time, but care just about the result (nodesForXPath, etc).

Are you in control of the XPath strings? If so, you should probably be using `try!`, because any mistake in your queries would be a programmer error.

I'm also not sure why you would call `nodes(forXPath:)` in void context at all—it doesn't have any useful side effects.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list