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

A null doesn't contain any information about what went wrong and unless you religiously check your objects for null values at every turn you just turned a clear stack trace into a search for waldo at the international waldo impersonators meetup.


Note that in Kotlin the return type is `Int?`, not `Int`. You can't forget to check for null because the compiler enforces it.

To your first point: Another example in the design space would be Rust which works very similarly to Kotlin but returns more information in the failure case.


> Note that in Kotlin the return type is `Int?`, not `Int`.

How does that fare with unnecessary boxing of primitives?


If the function isn't total (as in: for every string there is an int) then the boxing is necessary, no?


Not if you have user-defined value types (soon coming to Java).




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

Search: