How can I compare two or more values using the match function in Kotlin

Asked

Viewed 56 times

0

I’m using Kotlin with Mongo and have the following code snippet:

match(equal(Industry::addresses, Address::category, value = AddressCategory.MAIN.toString())!!)

The category of this address can be three types:

  • MAIN, DELIVERY and BILLING.

If the address MAIN not exist I want to take the DELIVERY. In case it doesn’t exist either I should take the BILLING. Always in this order of precedence. However, in this method he only makes the comparison of the MAIN and I want to be able to make all three.

So I wish I could use, in this method match, some kind of checker, so compare with the right values. I have tried using and, || and operador ternário, but always gave compilation error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.