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

Well, not really. What Kotlin has is exactly an Optional type. It's just a different syntax for it.


There's one difference between nullable/non-nullable types and Optional type, which is nesting, right?

I'd assume that while Kotlin's String? is equivalent to Optional<String>, Kotlin has no equivalent to Optional<Optional<String>>.

Which, personally, I think I'd prefer Kotlin's approach, because that means you can do `maybeString = "exists"`, which is more readable than `maybeString = Optional::Exists("exists")`


Sure. In Haskell you join them, but just not allowing it perhaps better.

Also, you can still nest them in Kotlin, since you can have a nullable type inside generics.




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

Search: