Introduction
Ensure helps you run some code no matter what happens before. It is useful to clean up things like closing files or freeing resources.
You open a file and want to make sure it closes even if an error happens.
You start a network connection and want to close it no matter what.
You allocate memory or resources and want to release them safely.
You want to print a message or log something after a block of code runs, even if it fails.