swift 空合运算符

356 阅读1分钟

定义 public func ?? (optional: T?, defaultValue: @autoclosure () throws -> T) rethrows -> T

a??b a不为nil则返回a,否则返回b,a一定是可选项,若b为不可选项,返回a时会拆包