# How to define an enum?
PREREQUISITE
Open the respective .kdata file.
For example to define lottery status as an enum, open LotteryData.kdata file in eclipse.
Define the enum data using keyword
enumas follows:enum LotteryStatus => OPEN ("Open") | CLOSE ("Close") | CANCELLED // value defaults to key.Note: Dont forget to save the file
enter sbt shell, run
compilecommand to access the enum.
# Sample Usage:
def isLotteryOpen(currentStatus: String): Boolean = {
currentStatus == LotteryStatus.OPEN.name
}
def isLotteryCancelled(currentStatus: LotteryStatus): Boolean = {
currentStatus == LotteryStatus.CANCELLED
}