Hi, I am trying to give a value to a entity (creat...
# getting-started
d
Hi, I am trying to give a value to a entity (createEmail) based on entering enum type. Unfortunately, the value in the block is Unit type instead of CreateEmail. How to solve it? ( Method createErrorEmail is returning CreateEmail)
Copy code
val createEmail = {
            if (type == Type.ERROR) {
                dataProvider.createErrorEmail(id)
            }
        }
n
Try using a
when
statement.
Copy code
val createEmail = when (type) {
  Type.ERROR -> dataProvider.createErrorEmail(id)
}
https://kotlinlang.org/docs/control-flow.html#when-expression
s
@Dipendra Singh so to make it short (combining the remarks from earlier): drop the curly brackets and add an else-case.