4 ms·
Note that it would actually be (also changing to an array to make your abbreviation of the author's example make more sense): `if arr?.contains("a") == true {
by happytoexplain 5y ago
Note that it would actually be (also changing to an array to make your abbreviation of the author's example make more sense):
`if arr?.contains("a") == true { ... }`
or
`if arr?.contains("a") ?? false { ... }`
or
`if (arr ?? []).contains("a") { ... }`
or
`if let arr= arr, arr.contains("a") { ... }`
or
`if arr!= nil, arr!.contains("a") { ... }`
Optional<Bool> will not automatically unwrap where Bool is expected (since the compiler would have to assume nil is falsey, which is the kind of mushy shenanigans Swift explicitly denies).