jeudi 17 octobre 2019

Is there any way to negate if statement but except 'and' operator inside it in just single line else statement?

As I know so far, we can use not operator and rewrite if statement with not operator (or reverse all the signs) ! But since my code have more than 10 conditions in one if statement with many and operators, this seem makes my code duplicate and hard to read. As Example below:

If a>b and A>B and R<w<a<Q and ....
# Else case is just reverse like this
Else a<b and A<B and R>w>a>Q and ...
# I can not use just single Else without rewrite all condition (code will know a<b or A<B and ...)

Anyone have any ideas to clean this code? Or just keep the safe way is rewrite everything> Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire