https://kotlinlang.org logo
#random
Title
k

karelpeeters

07/10/2017, 8:45 AM
@Bob Well the compiler already does this for normal if statements on sealed classes, so it's not really a problem if there are many of them.
b

Bob

07/10/2017, 2:05 PM
karelpeeters: does what exactly?
k

karelpeeters

07/10/2017, 3:05 PM
It looks like my memory failed me, I thought this worked:
Copy code
sealed class Base

class A(val a: String) : Base()
class B(val b: String) : Base()

fun foo(base: Base) {
    if (base is A) {
        print(base.a)
    } else {
        print(base.b)
    }
}
But is doesn't...
I created an issue here: https://youtrack.jetbrains.com/issue/KT-18950, I couldn't really find a dupliciate.
2 Views