logoalt Hacker News

Surac • today at 7:51 PM • 1 reply • view on HN

What are they even good forbid we can’t validate the input with? A convenient way to write down parameter ranges. Nothing more


Replies

Jtsummers • today at 7:53 PM

Same uses as assert, but more options for what to do when they fail and you can move them (pre/post at least) into the function declaration so they act as a kind of executable documentation (when you compile the program so that they are executed and not dropped).