https://kotlinlang.org logo
Title
u

user

07/15/2022, 8:31 AM
Kotlin. How to get specific subclass of sealed class? I'm using kotlin sealed class. And I need to retrieve specific subclass. My sealed class: sealed class Course( val type: Type ) { data class ProgrammingCourse(val name: String, val detail: String) : Course(Type.PROGRAMMING) object LanguageCourse: Course(Type.LANGUAGE) ..... } For example I have function which can return Course: fun getCourse(): Course { if(...) return Course.ProgrammingCourse("test", "test") else return Course.LanguageCourse } In...