+ 1

What is nested if else statement? Thanks!

nested if else

14th Dec 2016, 2:22 AM
Irah Singson
Irah Singson - avatar
2 odpowiedzi
+ 9
You can use one if or else if statement inside another if or else if statement(s): if( boolean_expression 1) { /* Executes when the boolean expression 1 is true */ if(boolean_expression 2) { /* Executes when the boolean expression 2 is true */ } }
14th Dec 2016, 9:06 AM
Chill
+ 1
Generally speaking, you should be careful using with nested if statements. It increases what is called cyclomatic complexity, in other words you are creating several unique combinations of logic that take completely different paths in your code. If you are properly indenting your code, usually if you see more than three indentions on a single line, you should see this as a sign that you should rethink your organization and refactor.
15th Dec 2016, 7:43 AM
Matt Scott
Matt Scott - avatar