Conditional Logic

Computer science concepts in my own words.

If this, then that

Evaluating data based on a defined reason either allows the information to undergo additional computation or bypasses that circumstance until a certain condition is met or el…


This content originally appeared on DEV Community and was authored by Greg Ross

Computer science concepts in my own words.

If this, then that

Evaluating data based on a defined reason either allows the information to undergo additional computation or bypasses that circumstance until a certain condition is met or else. Pun intended.

if (condition) {
    run code 
}
if (condition) {
    run code
} else {
    run code
}

Checks

Maintaining sanity in a chain of commands starts with prioritizing the most important first. The data can be cascaded from one block to another until nothing checks true.

if (condition) {
    run code
} else if (other condition) {
    run code
} else if (other condition 2) {
    run code
} else {
   run code
}

Statements

The conditions that are checked are evaluated based on the expressions stated. An oversimplification would be a simple yes or no. Meaning true or false. Yes you can pass or no do not pass.

boolean lessThan = a < b; 
boolean lessThanOrEqual = a <= b;

boolean greaterThan = a > b;
boolean greaterThanOrEqual = a >= b;

boolean equal = a == b;
boolean notEqual = a != b;

More Complex

In addition to a daisy chain of if/else blocks. The conditions being evaluated can be intrinsically linked together and complicated.

int this = 7; 
int that = 13; 

boolean and = (this == 7 && that == 13); 
boolean or = (this == 7 || that == 13); 

boolean isTrueAndTrue = (this >= 10 && this <= 15) && (that >= 10 && that <= 15);
boolean isTrueOrFalse = (this >= 10 && this <= 15) || (that >= 10 && that <= 15);


This content originally appeared on DEV Community and was authored by Greg Ross


Print Share Comment Cite Upload Translate Updates
APA

Greg Ross | Sciencx (2021-11-03T03:58:15+00:00) Conditional Logic. Retrieved from https://www.scien.cx/2021/11/03/conditional-logic/

MLA
" » Conditional Logic." Greg Ross | Sciencx - Wednesday November 3, 2021, https://www.scien.cx/2021/11/03/conditional-logic/
HARVARD
Greg Ross | Sciencx Wednesday November 3, 2021 » Conditional Logic., viewed ,<https://www.scien.cx/2021/11/03/conditional-logic/>
VANCOUVER
Greg Ross | Sciencx - » Conditional Logic. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/03/conditional-logic/
CHICAGO
" » Conditional Logic." Greg Ross | Sciencx - Accessed . https://www.scien.cx/2021/11/03/conditional-logic/
IEEE
" » Conditional Logic." Greg Ross | Sciencx [Online]. Available: https://www.scien.cx/2021/11/03/conditional-logic/. [Accessed: ]
rf:citation
» Conditional Logic | Greg Ross | Sciencx | https://www.scien.cx/2021/11/03/conditional-logic/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.