I am looking for a way to evaluate a Swift Bool concisely in a single if statement, when the Bool is the property of an optional objec
Bool
if
Another possible solution is:
if objectWithBool?.bool ?? false { println("objectWithBool != nil && objectWithBool.bool == true") } else { println("objectWithBool == nil || objectWithBool.bool == false") }
The "nil coalescing operator" a ?? b is a shorthand for
a ?? b
a != nil ? a! : b