Hacker News new | past | comments | ask | show | jobs | submit login

Remove part of your sentence, and I think you've answered your own question.

> How do you know it's "the problem"? [...] because this is a Java interop call.

If you're making platform calls, you know you have to deal with nulls (or at least, you should, in my opinion). So you declare returns nullable and avoid passing nulls unless that's documented to be okay.

Kotlin's Elvis operator makes this really easy:

val a: String? = null val b: String = a ?: "alternative"




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: