Created
June 3, 2014 15:28
-
-
Save mrcljx/ee776083c1b0542dbe9f to your computer and use it in GitHub Desktop.
Bang.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
class Card {} | |
class Customer { | |
var optionalCard: Card? | |
var card: Card | |
init() { | |
self.card = Card() // required to avoid compiler error (card2 would be nil) | |
} | |
} | |
let john : Customer? = Customer() | |
let jane : Customer = Customer() | |
john!.optionalCard = Card() // We need the ! just because john is Optional | |
if let someJohn = john { | |
someJohn.card = Card() | |
} | |
jane.optionalCard = Card() | |
jane.card = Card() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If L10 would not have the
?
the whole example wouldn't need a!
.