Avatar
フーム
10:30 AM
private func failure<T>(message: @autoclosure () -> String) -> T { preconditionFailure(message) } infix operator !! func !!<T> (lhs: @autoclosure () throws -> Optional<T>, rhs: @autoclosure () -> String) -> T { do { return try lhs() ?? failure(message: rhs) } catch { print(error) // logging return failure(message: rhs) } } let num = Int("123") !! "絶対に数字" let data = try Data(contentsOf: URL(string: "https://www.google.com") !! "Google") !! "オフラインはあり得ない"