Last active
December 12, 2016 07:53
-
-
Save rmnblm/90dd009f55ca4878c61d7a98a31b2638 to your computer and use it in GitHub Desktop.
Swift: Optionals Part 3
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
// Declare two optional values | |
var firstName: String? = "Roman" | |
var lastName: String? = "Blum" | |
// Option 1: Nested | |
if let firstName = firstName { | |
if let lastName = lastName { | |
// Use firstName and lastName | |
} | |
} | |
// Option 2: Seperated by comma | |
if | |
let firstName = firstName, | |
let lastName = lastName { | |
// Use firstName and lastName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment