I'm getting this error Missing return in a function expected to return "User" for this code:
var winner : User? {
if player1TotalScore > player2TotalScore {
return player1
} else if player1TotalScore == player2TotalScore {
return nil
}
}
The most curious thing about this is that I do basically the same thing a few lines up:
var opponent : User! {
if player1.isEqual(User.currentUser()) {
return player2
} else {
return player1
}
}
What am I doing wrong in the first bit of code?