Alejandro Serrano.Mena
02/07/2024, 10:51 AMwhen
expressions -> https://github.com/Kotlin/KEEP/issues/371Emil Kantis
02/07/2024, 12:47 PMfun render(status: Status): String = when (status) {
Status.Loading -> "loading"
is Status.Ok(info = []) -> "no data"
is Status.Ok -> status.info.joinToString()
is Status.Error(problem = Problem.CONNECTION) -> "problems with connection"
is Status.Error(problem = Problem.AUTHENTICATION) -> "could not be authenticated"
else -> "unknown problem"
}
Alejandro Serrano.Mena
02/07/2024, 1:17 PMLoney Chou
02/07/2024, 5:15 PMphldavies
02/08/2024, 9:18 AMif
is a nicer syntax and less surprising for those coming from similar pattern guard constructs (i.e. rust or scala), and is potentially semantically clearer (and has no confusion with disjunctions)phldavies
02/08/2024, 9:23 AMAlejandro Serrano.Mena
02/08/2024, 9:24 AM