📅  最后修改于: 2022-03-11 14:53:31.990000             🧑  作者: Mango
We can use let to achieve this behaviour.
response.code().let {
when {
it == 200 -> handleSuccess()
it == 401 -> handleUnauthorisedError()
it >= 500 -> handleInternalServerError()
else -> handleOtherErrors()
}
}