Hexa
03/16/2019, 9:07 AMif(carId.isNullOrEmpty()) statement here as it looks duplicated code to me.
deferredCarIdResult.await() can return an empty string like this "" so I return CarNotFound("not found") but when the coroutines timeout I also return CarNotFound("not found")
val carId = runBlocking {
withTimeoutOrNull(10000L) {
deferredCarIdResult.await()
}
} ?: return CarNotFound("not found")
if(carId.isNullOrEmpty()){
return CarNotFound("not found")
}Dominaezzz
03/16/2019, 9:13 AM?: return CarNotFound("not found")?Dominaezzz
03/16/2019, 9:17 AM.takeUnless { it.isEmpty() } right after the await.Hexa
03/16/2019, 9:30 AM?: return CarNotFound("not found") is more readable so I'll do thatHexa
03/16/2019, 9:32 AM.takeUnless { it.isEmpty() } can I lose the if the statement then @Dominaezzz?Dominaezzz
03/16/2019, 9:33 AMHexa
03/16/2019, 9:40 AMtakeUnless be more idiomatic in this case? @Dominaezzz. it's not as readable but i think it just takes getting used toDominaezzz
03/16/2019, 9:43 AMDominaezzz
03/16/2019, 9:44 AMHexa
03/16/2019, 9:44 AM