The movie is a metaphor for a while loop. A while loop is a basic computer programming coding feature.
The metaphor used to explain what a while loop is, is comparing it to someone who has lost your keys. When you lose your keys, you look for your keys until you have them, once you have them you stop looking. But you wouldn’t search in the first place if you originally hadn’t lost them.
The main features of a while loop is that a Boolean condition (a true or false statement) is evaluated first. In this case it is the question of “do you have your keys, true or false?” If you have your keys, then you don't search for them (complete the actions/code within the while loop). But if you don't have your keys , then you search for them until you have found them (you keep on evaluating and working your way through your action/code until the initial Boolean condition changes) and through completing this process you change the original Boolean condition of “do you have your keys” to true. Once you have your keys then you stop searching for them and this is the finish of the while loop.
In pseudo code:
while (You don’t have your keys) {
search new room;
}
while (You don’t have your keys) {
search new room;
}
No comments:
Post a Comment