Substitiute for if and else

I am really tired from typing and thinking all the possible scenarios to meet certain conditions as it could lead upto alot of if and else statements which is more prone to errors.I would like to know if there is any alternative for it although I have tried using for loop and was also success-full some times.So if you know more efficient and convenient method please share.

Many languages have the “switch…case” structure.
Get to learn it if you haven’t done so.

1 Like

Switch case is not of much help as conditions can’t be implemented and many other reasons.
I not saying to replace if else entirely but use it with some other concepts like loops . I just want to avoid excessive use of if else alone as its error prone and very lengthy way of coding.

It depends on what you’re trying to accomplish. Data structures like arrays/lists/dictionaries can be useful in sorting/querying data without excessive use of if->else statements. What sort of problem are you trying to solve?

1 Like

In the contest Ocean of Code I am trying to give priority to cells of the row i.e. 0-14 based on the movement of the opponent.I am doing using with pure if else till now but now I think I should look for other alternatives.If u have any suggestions please give.