0
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.

Ivo
  • 18,659
  • 2
  • 23
  • 35
  • 1
    What is safeLet here? I assume this is a function which takes some nullable values and a lambda, and then executes that lambda if all values are non-null. But can you add the entire function(s) in the question for better understanding? – Arpit Shukla Jun 28 '22 at 12:15

1 Answers1

1

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)
    }
}
Ivo
  • 18,659
  • 2
  • 23
  • 35