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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -