Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. var costume: String? = "Werewolf"
  2. println(costume) // Optional("Werewolf")
  3.  
  4. costume = costume + " dressed as Michael J Fox" // Compiler Error
  5.  
  6. if let something = costume {
  7. // The value is not nil, use it with confidence
  8. something = something + " dressed as Michael J Fox"
  9. println(something) // "Werewolf dressed as Michael J Fox"
  10. } else {
  11. // The value is nil
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement