swift ternary statement

Swift
myBool = str1 != nil ? true : false
print(myBool)
Source

Also in Swift: