dimanche 5 août 2018

Is there a more elegant way to write these conditions?

    if(first - second >=2 || first - second <=-2 || first - third >=2 || first - third <=-2 || second - third >=2 || second - third <=-2)

It's disgusting.

I have three values that have to be checked, and if any two of them have a >= 2 difference, then I run through some tasks.

I'm curious, can you suggest a way that would make this more pleasant? Thanks

Aucun commentaire:

Enregistrer un commentaire