What are assertions? Can somebody explain it? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 13

What are assertions? Can somebody explain it?


13th Oct 2018, 3:09 PM
🔥EACY🔥 - avatar
2 ответов
+ 2
An assertion is a command that assumes something as necessarily true, then raises an error otherwise. It's useful for debugging - you insert an assertion in your code where you expect, for example, a variable to have a certain value. If it hasn't, your code fails with a clear message, instead of running until something goes wrong and you have to investigate why.
13th Oct 2018, 5:40 PM
Emerson Prado
Emerson Prado - avatar
+ 3
Thanks for explaining
13th Oct 2018, 8:24 PM
🔥EACY🔥 - avatar