Good night pricey colleagues, please assist me determine it out. Easy methods to perceive this a part of the code. Why”!”it’s situated between two brackets []![].
What’s the which means of this expression?
self.desk[number]![alpha]
class GameDesk {
var desk : [Int: [String: Chessman]] = [:]
init() {
for i in 1...8 {
desk[i] = [:]
}
}
subscript(alpha: String, quantity: Int) -> Chessman? {
get {
return self.desk[number]![alpha]
}
set {
if let chessman = newValue {
self.setChessman(chess: chessman, coordinates: (alpha, quantity))
} else {
self.desk[number]![alpha] = nil
}
}
}
func setChessman(chess: Chessman, coordinates: (String, Int)){
let rowRange = 1...8
let colRange = "A"..."Z"
if(rowRange.comprises(coordinates.1) && colRange.comprises(coordinates.0)) {
self.desk[coordinates.1]![coordinates.0] = chess
chess.setCoordinates(char: coordinates.0, num: coordinates.1)
} else {
print("Coordinates out of vary")
}
}
}
The which means of this piece of code doesn’t attain me