package main enum PaymentResult { Accepted(String) Rejected(String) Pending } fun describe(result: PaymentResult): String { var description = "" match (result) { PaymentResult::Accepted(id) -> { description = "accepted " + id } PaymentResult::Rejected(reason) -> { description = "rejected " + reason } PaymentResult::Pending -> { description = "pending" } } return description } fun main() { val result = PaymentResult::Accepted("payment-1") println(describe(result)) }