Hi, say after send a request , the response have t...
# getting-started
x
Hi, say after send a request , the response have two type , when success
Copy code
@Serializable
data class Success(
    var code: Int, // maybe 0
    var content: String,
) {}
while fail:
Copy code
@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?
Copy code
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 ?
👀 1
a
I think you can use railway oriented programming here