samedi 22 septembre 2018

Kotlin: redundant if statement

I have this code:

val leftEnoughRoom = if(fx1 > eachSideBesidesFace){
    true
}else{
    false
}

And get the warning:

This inspection reports if statements which can be simplified to single statements. For example:  
if (foo()) {
   return true
} else {
   return false
}
can be simplified to return foo().

What the hell is this want from me? When I do:

if(fx1 > eachSideBesidesFace){
    val leftEnoughRoom = true
}else{
    val leftEnoughRoom = false
}

Then leftEnoughRoom is not reachable below any more

Aucun commentaire:

Enregistrer un commentaire