When I want to check if an Optional Bool is true, doing this doesn\'t work:
var boolean : Bool? = false
if boolean{
}
It results in this error:
var enabled: Bool? = true
if let enabled = enabled, enabled == true {
print("when is defined and true at the same moment")
}
if enabled ?? false {
print("when is defined and true at the same moment")
}
if enabled == .some(true) {
print("when is defined and true at the same moment")
}
if enabled == (true) {
print("when is defined and true at the same moment")
}
if case .some(true) = enabled {
print("when is defined and true at the same moment")
}
if enabled == .some(false) {
print("when is defined and false at the same moment")
}
if enabled == (false) {
print("when is defined and false at the same moment")
}
if enabled == .none {
print("when is not defined")
}
if enabled == nil {
print("when is not defined")
}