Ofir Bar
03/12/2020, 8:53 AMfun getCityById(selectedCityId: Int): City {
var city : City? = null
viewModelScope.launch {
city = locationRepository.getSingleCityFromDatabaseById(selectedCityId)
}
return city //Compilation error message: type mismatch, Required:City, found: City?
}
fun getListOfLanguagesByIds(selectedLanguages: List<Int>): List<Language> {
viewModelScope.launch {
return supportedLanguagesRepository.getLanguagesFromDatabaseById(selectedLanguages.toIntArray())
}// Compilation error above message: 'return' is not allowed here
}
fun getExpertiseFieldById(expertiseFieldId: Int): ExpertiseField {
lateinit var expertiseField : ExpertiseField
viewModelScope.launch {
expertiseField = expertiseFieldsRepository.getSingleExpertiseFieldFromDatabaseById(expertiseFieldId)
}
return expertiseField
//Seems to work, but I am afraid expertiseField will be returned uninitialized.
}
Raul Tunduc
03/13/2020, 7:11 AM