If you need a infix operator that traps, here you have one ;)
infix operator ?! : NilCoalescingPrecedence
func ?! <T>(optional: T?, noreturn: @autoclosure () -> Never) -> T {
switch optional {
case .some(let value):
return value
case .none:
noreturn()
}
}
let x: Int? = nil
let y: Int = x ?! fatalError("Your message here")
--
Adrian Zubarev
Sent with Airmail
Am 8. Februar 2017 um 16:00:24, Haravikk via swift-evolution
([email protected]) schrieb:
I say it's a bit of an odd operator since it doesn't actually trap.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution