I have the following playground code :
typealias ChessItemPosition = (alpha:Character, num:Int)
typealias Chessman = Dictionary<String,ChessItemPosition?>
var chessmans : Chessman = [:]
chessmans["White king"] = (alpha : "e", num : 2)
chessmans["Black king"] = (alpha : "e", num : 6)
chessmans["Black queen"] = nil
var itemPosition = chessmans["Black queen"]
if let chessItemPosition = itemPosition {
print("Current position is : \(chessItemPosition!.alpha)\(chessItemPosition!.num)")
} else {
print("Black queen is dead")
}
Why do I need to use !. syntax to access the tuple content? When I have
var markCount : Int? = 8
if let markCount_ = markCount {
print("\(markCount_)")
}
and no ! is required here. What am I missing here?