Reputation: 39
I have this function on my Ktor + Exposed App.
override suspend fun createNewCourse(course: CourseModel): Flow<CourseModel> {
transaction {
CoursesTable.insert {
it[requiredCourseId] = course.requiredCourse?.id!!
it[category] = course.category?.id!!
it[isPopular] = course.isPopular == true
it[position] = course.position
it[nameEN] = course.name.en
it[warningEN] = course.warning.en
}
}
It doesn't compile. Sometimes some variables (like "warningEN") can be null and I dont want to insert nothing for this field.
How to make it?
Type mismatch. Required:TypeVariable(S) Found: String?
Upvotes: 1
Views: 855
Reputation: 39
My solution:
it[position] = course.position?.let { course.position!! } ?: null
Upvotes: 2