How to get Optional<String> from String? and String in Kotlin -
i have overridden function in kotlin returns optional<string>. how convert string? , string types optional<string>?
example:
override fun getcurrentauditor(): optional<string> { val username = securityutils.currentuserlogin return username ?: system_account } from above example:
username string?
system_account string
i'm getting errors on return statement both variables not optional<string> types.
just create 1 wrap string value, in case:
override fun getcurrentauditor(): optional<string> { val username = securityutils.currentuserlogin return optional.of(username ?: system_account) }
Comments
Post a Comment