read the transcript!
Some languages have an
assert keyword that you can use to crash the program if a condition fails. Assertions let you:
- come up with something that should ALWAYS be true
- immediately crash the program if it isn’t this variable is undefined!!!
Illustration of a program, represented by a box with an unhappy face.
program (thinking): “this variable is undefined!!! STOP EVERYTHING!”
This is a great way to force yourself to think about what’s ALWAYS true in your program, and check if you’re right.
Illustration of a smiling stick figure with curly hair.
person (thinking): “the radius can never be 0, right? or can it?”