Use dot notation for enum variants
This commit is contained in:
parent
ab783c33ed
commit
117d188194
13 changed files with 162 additions and 154 deletions
|
|
@ -8,13 +8,13 @@ enum PaymentResult {
|
|||
|
||||
fun describe(result: PaymentResult): String {
|
||||
return match (result) {
|
||||
PaymentResult::Accepted(id) -> "accepted " + id
|
||||
PaymentResult::Rejected(reason) -> "rejected " + reason
|
||||
PaymentResult::Pending -> "pending"
|
||||
PaymentResult.Accepted(id) -> "accepted " + id
|
||||
PaymentResult.Rejected(reason) -> "rejected " + reason
|
||||
PaymentResult.Pending -> "pending"
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val result = PaymentResult::Accepted("payment-1")
|
||||
val result = PaymentResult.Accepted("payment-1")
|
||||
println(describe(result))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue