How do I get filtered Subclasses from sealed Class

Solution 1:

Use clazz == Number.One::class.

Currently, you’re using clazz::class which is KClass<out KClass<out Number>>, the class of what was already a class.

And you forgot the ::class at the end.

However, you’re filtering to find out which subclass is the class you already know so there’s no point. You could just replace you’re whole line of code with val subclasses = listOf(Number.One::class).