is there a way to have extension function only app...
# announcements
a
is there a way to have extension function only applicable to sealed classes, like (pseudo):
Copy code
inline fun <reified T : Any> T.ext() "where T::class.isSealed" {}
m
I’m curious about your use case 🙂
3
z
The "sealed" characteristic of a class is not represented in the type system, unlike with enums, so there's no way to do this for all sealed classes without reflection. You could give
T
an upper bound of a specific sealed class, but it would have to be a specific one.
👍🏼 1