The coding term that my metaphor represents is the programming operation if/else, through using the way eyes react to changing light. If it’s dark, the pupil of the eyes are larger, else if it’s light the pupils are smaller.
The code would look like this (the actual programming terms are in bold):
if (it’s nighttime) {
pupils.larger();
} else if (it’s daytime) {
pupils.smaller();
}
In terms of using if/else, you put “if” before a trigger that will affect the pupils. In this case it’s the level of darkness, but in programming it could be another kind of trigger, such as “mousePressed”, which means that if the mouse was pressed, the pupil will get larger.
There can be multiple statements under an “if”, which means that many things can happen under the situation of it being nighttime, or daytime.
“Else if” means “alternatively”. By using it you add a new situation (e.g. or else if light doesn’t exist, you wouldn’t see the eye at all and the pupil would be irrelevent. Or else if it was dusk, the pupil would not be at its biggest or smallest, it would be medium sized).
When only putting “else”, you are referring to all other situations not listed under any “if” or “else if”.
No comments:
Post a Comment