How can I efficiently write a complex if or switch condition that depends on a combination of two (or more) variables?


Loading ....
 

Software https://softwareengineering.stackexchange.com/questions/387732/how-can-i-efficiently-write-a-complex-if-or-switch-condition-that-depends-on-a-c

In my current case, I have got two variables. Let’s call them actions and status for ease of usage. They can have any value between 1 and 9. I’m attempting to compose this in the way that is most readable, and so far I am not happy with the outcomes. What I’ve successfully gotten down to is that the following

If(actions ==1)
if(status==1)
    else if(status==2
    else...
else if(action==2)
    if(status==1)
    else if(status==2
    else...
else....
  

This alternative, while it works, doesn’t seem clean. Is there a way? The one thing which springs to mind for me is.

How would this be prolonged whether there were over just two subactions, or for variables?

 


Loading ....
 

Be the first to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.