https://kotlinlang.org logo
#announcements
Title
# announcements
s

Siva

07/03/2018, 3:46 PM
i am trying to convert my following sequence code to Functional style. any idea how to do so. sequence code
Copy code
fun start(code : String)  {
        val config = service.getConfig(code)
        if( config == null ) {
            return
        }
        // do actual biz logic based on config.
    }
functional style
Copy code
fun start(code : String)  {
        val eitherConfig = service.getConfig(code)
        when(eitherConfig) {
            is Either.Left -> return
        }
        val config = either.b

        // do actual biz logic based on config.
    }
doubt: i am not sure how to break function when Right condition occurs and return it. or continue function with right flow.