Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm very happy about this - lack of null safety and implicit downcasts are two of the biggest problems with Dart/Flutter, which I otherwise really enjoy working in. I've gotten in the habit of adding "assert(x != null)" in all of my methods.


> 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?


Yeah, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: