https://kotlinlang.org logo
Title
e

Enrico Hofmann

10/30/2018, 12:36 PM
hi togeth i am a java developer. and i will hove something like nullable/optional in a data class. how can i do that ?
r

RobinVdB

10/30/2018, 1:20 PM
I don't recommened the use of optional in kotlin, rather use null. Optional tries to solve NPE in java. Kotlin is build with null safety in mind. Look at the docs that Shawn mentoined for what kotlin has built in.
k

karelpeeters

10/30/2018, 1:22 PM
If you would implement this in Kotlin you'd use sealed classes: https://kotlinlang.org/docs/reference/sealed-classes.html
👆 1