3 ms·
> I've gotten in the habit of adding "assert(x != null)" in all of my methods Is this not useless most of the time, since you'll usually get an exception (with
by cbolton 6y ago
> I've gotten in the habit of adding "assert(x != null)" in all of my methods
Is this not useless most of the time, since you'll usually get an exception (with stack trace) when the value is used?
- mindvirus 6y agoYeah, but at least this catches it early - i.e. if a branch/if-statement uses the field, it might not always be hit when testing things out. Unit tests _should_ catch these things, but so should the type system, and for my side projects I'm kinda fast and loose with testing for better or for worse.