Created
April 27, 2020 10:55
-
-
Save jeetdholakia/dd247ec9b143c2ca69e158906188314b to your computer and use it in GitHub Desktop.
Unwrapping optionals in swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let optionalNumber = Int("365") | |
// The optionalNumber is an optional Int | |
let unwrappedNumber = optionalNumber! | |
// The unwrappedNumber is Int and has a value of 365 | |
let optionalFirstName = ["firstName": "Jeet", "lastName": "Smith"]["firstName"] | |
// The optionalNumber is an optional String | |
let unwrappedFirstName = optionalFirstName! | |
// The unwrappedNumber is String and has a value of "Jeet" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment