|
In this sample code from the SquareGame class, the variable 'key' is declared, but not assigned to any value. Later on, a while loop uses the 'key' variable in its expression(key=0). How does the while statement tell what value 'key' is, if 'key' has not been assigned to anything.
method void run() {
var char key;
var boolean exit;
let exit = false;
while (~exit) {
// waits for a key to be pressed.
while (key = 0) {
let key = Keyboard.keyPressed();
do moveSquare();
}
|