https://kotlinlang.org logo
#getting-started
Title
# getting-started
g

Gasan

12/12/2023, 5:58 PM
Hi all, If my kotlin interface returns a nullable value, how can I define an implementation of this interface in java that returns optional? That seems to me what nullable kotlin type translates to in java world
d

Daniel Pitts

12/12/2023, 6:01 PM
The Nullable type in Kotlin is just the normal type in Java, so Java clients would have to use null checks.
g

Gasan

12/12/2023, 6:02 PM
😞
thank you
d

Daniel Pitts

12/12/2023, 6:03 PM
You could provide separate
optionalFoo
wrappers that return
Optional.ofNullable(foo())
g

Gasan

12/12/2023, 6:47 PM
right thank you