dG
02/22/2019, 12:40 PMval foo : SomeInterface = inputVariable
val bar = if (foo is implA) (foo as implA) else (foo as implB)
Here bar
will be of type SomeInterface. Is it possible to somehow use implementation specific stuff available on both implementations but not on the interface, so bar.fieldOnlyOnImplementations
?diesieben07
02/22/2019, 12:47 PMursus
02/22/2019, 5:47 PMharry.singh
02/23/2019, 8:15 AMwhen
be helpful here?
when (foo) {
is implA -> implA.fieldOnlyOnImplementation
is implB -> implB.fieldOnlyOnImplementation
}
Using smart cast would help to use implementation specific methods here