on page 189, the code for structure seems to be a bit strange to me. After I checked the code to implement the tic-tac-toe game, there is a line of code that looks like this:
// Return true if all the board positions are filled or there is a winner
var isFinished: Bool {
return winner != nil || !board.contains { $0 == nil }
}
My question is whether isFinished assigned a function, closure or some other stuff? I am just confused about this syntax. Cuz if it is a closure shouldn’t it look like this with a assignment operator?
// Return true if all the board positions are filled or there is a winner
var isFinished: Bool = {
return winner != nil || !board.contains { $0 == nil }
}