i have a code that does something like this:
while (doorIsLocked()) {
knockOnDoor();
}
openDoor();
but i want to be polite and always knock on the door before i open it.
i can write something like this:
knockOnDoor();
while (doorIsLocked()) {
knockOnDoor();
}
openDoor();
but i'm just wondering if there's a better idiom that doesn't repeat a statement.
thanks.