Recently joined a new project and noticed, in project expression false as Bool?
returns nil
instead of Optional(false)
.
XCode 14.1, 14.2. Same expression in playground returns Optional(false). All swift compiler optimizations are disabled. What could case this behavior?
CodePudding user response:
Someone redefined init(booleanLiteral:)
in the project.
extension Bool?: ExpressibleByBooleanLiteral {
public init(booleanLiteral bool: Wrapped) {
self = bool ? bool : nil
}
}