Conditionals

We can use if statements to run a code statement only if certain conditions are met.

For example:

if (isRainingOutside == true) {
    takeUmbrella = true;
} else {
    takeUmbrella = false;
}

For our game, we should use if statements to determine if a player has 3 vertical, horizontal, or diagonal matches.

Inside the () beside if, you should specify a Boolean expression. Booleans are true or false statements. We can utilize this in our if statement. If the expression is true, the code inside { } is executed. If the expression is false, the code inside { } after the else statement is executed.

You can also connect Boolean expressions together using the && (AND) and the || (OR) operator.

Take a look at the CheckWinner() function in MainActivity.kt and think about what all the connected && statements are doing.