-
-
Save josefigueredo/262bde06fa18dd5b2ca64fd10e26d641 to your computer and use it in GitHub Desktop.
Kotlin extension function to convert Java8 Optional<T> to Kotlin nullable T?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T : Any> Optional<T>.toNullable(): T? = this.orElse(null); | |
fun <T : Any> T?.toOptional(): Optional<T> = Optional.ofNullable(this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment