20 lines
434 B
Text
20 lines
434 B
Text
package main
|
|
|
|
enum PaymentResult {
|
|
Accepted(String)
|
|
Rejected(String)
|
|
Pending
|
|
}
|
|
|
|
fun describe(result: PaymentResult): String {
|
|
return match (result) {
|
|
PaymentResult.Accepted(id) -> "accepted " + id
|
|
PaymentResult.Rejected(reason) -> "rejected " + reason
|
|
PaymentResult.Pending -> "pending"
|
|
}
|
|
}
|
|
|
|
fun main() {
|
|
val result = PaymentResult.Accepted("payment-1")
|
|
println(describe(result))
|
|
}
|