class Foo(val name: String) : Something() data class Bar(val name: String) : Something() data class Baz(val name: String) : Something() fun doSomething() { when (val something: Something = getSomething()) { is Foo -> {} is Bar -> {} is Baz -> {} } } potatotips #81 👍