Consider this piece of code
interface Foo
interface Bar
class Aclass: Foo, Bar
fun main(args: Array<String>) {
val aclass = Aclass()
when (aclass) {
is Foo -> println("foo")
is Bar -> println("bar")
}
}
I want it to print “foo” and “bar” because the class implements the two interfaces.
But it prints only “foo”.
I can chain ‘if’ statements, like “if (it is Foo) {…}” to make it work but is there a way to do it with a when statement ?