problem with "while" loop: different with integer and boolean values
in
Programming Questions
•
1 year ago
hello everyone,
i came across a problem with the "while" loop that i can't seem to figure out.
in the reference, you can find this code:
- int i = 0;
- while (i < 80) {
- line (30, i, 80, i);
- i += 5;
- }
i wanted to try something similar with a boolean, such as
- boolean a = true;
- int i = 0;
- while (a = true) {
- line (30, i, 80, i);
- i += 5;
- if (i > 79) {
- a = false;
- }
- }
this must be silly, but does anybody know why the result is different?
1