I have lots of code in my project of this style:
let hasQuestionsRemaining = user.numberOfCredits > 0.0
where numberOfCredits
is a Double?
. So I get the error : Binary operator '>' cannot be applied to operands of type 'Double?' and 'Double'
.
So now I use:
var hasQuestionsRemaining = false
if let numberOfCredits = user.numberOfCredits, numberOfCredits > 0.0 {
hasQuestionsRemaining = true
}
Is there a more efficient way to do this?