https://kotlinlang.org logo
#announcements
Title
# announcements
c

cleiter

08/30/2016, 4:03 PM
so i have this situation where i can't use an if/else with some legacy java code
Copy code
/* this is package private in another package */ abstract class Parent
class A : Parent()
class B : Parent()

fun x() {
    if (true) A()
    else B()
}
since it's an expression kotlin tries to get the common return type which is
Parent
and then complains that it's not accessible. i'm not interested in the return type. i don't feel like writing
as Any
at the end of the
if
, is there a better solution?