What is the role assert that?

This keyword assert we call "assert" is false, the program automatically AssertionError crashes and throws an exception when the key behind the condition.
Under what circumstances would we need this code? When we would be very easy to use when the test program, because rather than let the wrong conditions cause the program to crash in the future somehow, that moment is better to appear at the wrong conditions we achieve "self-destruct."
In general we can use Ta placed checkpoints in the program, when the need to ensure that the program is true to a certain condition to make the program work, then, assert keyword is very useful.

Guess you like

Origin www.cnblogs.com/qwksjy/p/11271027.html