extension Optional where Wrapped == Bool { var bool: Bool { switch self { case .some(let value): return value == true case .none: return false } } } var foo: Bool? = true if foo.bool { print("Hello!") }