I have a enum class like this:
enum class ParkingLotStatus (val number:Int, var occupied: Boolean) {
LOT1(1,true),
LOT2(2,false)
}
I want to select the enum instance using the number variable. If I get user input as 1, I want to be able to pick the enum intense LOT1 based on the variable (constant?) number.
One way would be to iterate over all the enum instances and check if the input matches the variable
Is there a more simple and not resource intense way to do this?