Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Swift code:
func debug<T>(..., statement: () throws -> T) rethrows {
  let result = try statement()
  ...
  return result
}
It should compile away in optimized builds.

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It's "conditional conformances". We intended to implement it in Swift 4 and didn't quite finish. It'll probably be in 4.1.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Also stop making things optional for no reason.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Yeah, you can still do it with optionals, it just turns it from usa.states.flatMap { $0.cities } into something a little more complex/obscure.

But you should also be able to just declare the properties to be nonnull. IIRC, if you do that the bridging logic will automatically turn an unexpected nil return into an empty array.

  • Locked thread