Challenge: Fix the Code
Here is a challenge to highlight the importance of the scope of conditional expressions in a code.
We'll cover the following...
Study and run the code below:
Press + to interact
import std.stdio;void LemonadeOrPie() {bool existsLemonade = false;if (existsLemonade) {writeln("Drinking lemonade");writeln("Washing the cup");} elsewriteln("Eating pie");writeln("Washing the plate");}
But when you run this program, you will see that it displays ‘Washing the plate’ even when the logical expression existsLemonade is true:
Drinking Lemonade
Washing the cup
Washing the
...