Skip to content

Instantly share code, notes, and snippets.

@jeetdholakia
Created April 27, 2020 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeetdholakia/dd247ec9b143c2ca69e158906188314b to your computer and use it in GitHub Desktop.
Save jeetdholakia/dd247ec9b143c2ca69e158906188314b to your computer and use it in GitHub Desktop.
Unwrapping optionals in swift
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