Check out example codes for "swift ternary statement". It will help you in understanding the concepts better.

Code Example 1

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

Learn ReactJs, React Native from akashmittal.com