This is my favorite size project. It allows us to be pedantic about every detail.
When the key press event is triggered current is to be increased or decreased if two conditions are met. One shouldn't check just one, take action then change it back if the other condition isn't met.
The else is there because we don't need to check the other condition if the first is true.
Not that the original code doesn't work. I just want to execute instructions needed and avoid unnecessary ones if it is simple enough. The case where we try to increase beyond the array size would still trigger the second check. Even more correct would be:
When the key press event is triggered current is to be increased or decreased if two conditions are met. One shouldn't check just one, take action then change it back if the other condition isn't met.
something like... The else is there because we don't need to check the other condition if the first is true.Not that the original code doesn't work. I just want to execute instructions needed and avoid unnecessary ones if it is simple enough. The case where we try to increase beyond the array size would still trigger the second check. Even more correct would be:
To make it uglier the if can go... As it won't check the next condition if the first fails.This hideous bit...
Could be slightly less ugly and one character shorter Then we can shovel the other conditions inthere too! You see, with just a little effort we may improve nothing.