If you are trying to have a
() -> CreateEmail
, you need to provide an else branch:
val createEmail = {
if (type == Type.ERROR) {
dataProvider.createErrorEmail(id)
} else {
// some other CreateEmail
}
}
or use a when statement similar to what
@Nolan suggested, but wrapped in braces:
val createEmail = {
when (type) {
Type.ERROR -> dataProvider.createErrorEmail(id)
// Other branches
}
}
You can also specify the type explicitly to get a compiler error and avoid type inference altogether:
val createEmail: () -> CreateEmail = ...