Expand Gotlin language and tooling
This commit is contained in:
parent
8f4f858d86
commit
de1262b4cf
41 changed files with 6059 additions and 379 deletions
22
examples/enums.gt
Normal file
22
examples/enums.gt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue