I’ve build a custom operator for this: https://gist.github.com/DevAndArtist/dad641ee833e60b02fd1db2dbb488c6a
infix operator ?! : NilCoalescingPrecedence func ?!<T>(optional: T?, noreturn: @autoclosure () -> Never) -> T { switch optional { case .some(let value): return value case .none: noreturn() } } // Usage let test: Int? = nil test ?! fatalError("Message") -- Adrian Zubarev Sent with Airmail Am 6. Oktober 2016 um 05:35:53, Jonathan Hull via swift-users (swift-users@swift.org) schrieb: I used to be able to use ?? with fatalError(“Message”) to trap with a custom message in case of nil. This no longer works in Swift 3 (I think because of the update to never type) _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users