Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var costume: String? = "Werewolf"
- println(costume) // Optional("Werewolf")
- costume = costume + " dressed as Michael J Fox" // Compiler Error
- if let something = costume {
- // The value is not nil, use it with confidence
- something = something + " dressed as Michael J Fox"
- println(something) // "Werewolf dressed as Michael J Fox"
- } else {
- // The value is nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement