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

stepango

05/10/2017, 11:52 AM
I want inherit java class from kotlin's
Function0<Unit>
but getting
Copy code
return type void is not compatible with Unit
  where R is a type-variable:
    R extends Object declared in interface Function0
from the other hand i can't specify return type as
kotlin.Unit
in java. Is there any way to do it?
stackoverflow 1
m

miha-x64

05/10/2017, 12:01 PM
stepango: you can use
kotlin.Unit
type and
kotlin.Unit.INSTANCE
object from Java.
s

stepango

05/10/2017, 12:05 PM
in this case I'm getting
funname clashes with funname; incompatible return type
m

miha-x64

05/10/2017, 12:07 PM
Copy code
public class KFuncExample implements kotlin.jvm.functions.Function0<Unit> {
    @Override public Unit invoke() {
        return Unit.INSTANCE;
    }
}