xun su
05/18/2023, 12:57 AM@Serializable
data class Success(
var code: Int, // maybe 0
var content: String,
) {}
while fail:
@Serializable
data class Fail(
var code: Int, // maybe 1
var err: String,
) {}
I wanna know what is the elegant way to handle the two situation?
val res:Response = sendRequest<what should I put here?>()
// and how should I define Response?
if(res instanceOf Success){...} else if (res instanceOf Fail){...}
and is the code above a proper way ?Alejandro Rios
05/18/2023, 3:35 AM