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

Kotlin has some functionality for this that help the compiler. A good example is the isNullOrBlank() extension function on String? (nullable String). It has a contract that treats the string as not null after it returns false. So if you do a null check, it smart casts to a non nullable string without generating a compile error.

There are a few more variations of that in the Kotlin standard library and you can write your own contracts as well. There's just not a whole lot you can do with it other than stuff like this. But it's useful.



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

Search: