Tag: optionals
-
Optionals in Swift 3
Swift Optionals A type the either has a “wrapped” value or is nil. e.g. let imagePaths = [“star”: “/glyphs/star.png”,”portrait”: “/images/content/portrait.jpg”,”spacer”: “/images/shared/spacer.gif”] Getting a dictionary’s value using a key returns an optional value, so imagePaths[“star”] has the type String? e.g. if let imagePath = imagePaths[“star”] { print(“The star image is at ‘(imagePath)'”) } else { print(“Couldn’t…