Let's cement this topic with a little treasure chest experiment:
- Declare three variables at the top of LearningCurve: pureOfHeart is a bool and should be true; hasSecretIncantation is also a bool and should be false, and rareItem is a string and its value is up to you.
- Create a public method with no return value, called OpenTreasureChamber, and call it inside Start.
- Inside OpenTreasureChamber, declare an if-else statement to check whether pureOfHeart is true and that rareItem matches the string value you assigned to it.
- Create a nested if-else statement inside the first, checking whether hasSecretIncantation is false.
- Add debug logs for each if-else case, save, and click on Play:
If you matched the variable values to the preceding screenshot, the nested if statement debug log will be printed out. This means that our code got past the first if statement checking for two conditions...