Home > Software design >  I need to get list with an argument
I need to get list with an argument

Time:06-28

private fun getRadResultList() {
    safeLet(
        arguments?.getString("referenceVisitId"), arguments?.getString("facilityId")
    ) { referenceVisitId, facilityId ->
        viewModel.getRadResultsWithId(referenceVisitId, facilityId)
    }
}

This is my previous code. The number of arguments requested by the function is now one. How do I return the facilityId in getRadResults()

private fun getRadResultList() {
    safeLet(
         arguments?.getString("facilityId")
    ) {  facilityId ->
        viewModel.getRadResults( facilityId)
    }
}

This code is the latest version. getRadResult() function wants only the facilityId.

CodePudding user response:

I'm assuming safeLetis the function mentioned in Multiple variable let in Kotlin

The thing is, that function is only necessary when wanting to check multiple variables. With a single variable you can use the default let. So like:

private fun getRadResultList() {
    arguments?.getString("facilityId")?.let { facilityId ->
        viewModel.getRadResults( facilityId)
    }
}
  • Related