将java转换为kotlin

我正在用orbit软件包开发一个Kotlin应用程序,但是我有一些问题来定义演员Unresolved reference: T

 class HelloActor():AbstractActor<T>,Hello 

应该是什么T参数? 在docs中: * @param <T> a class that represents the state of this actor.

我不太了解演员的框架,但基于你在评论中给出的细节,我认为你应该用任何Any替换T.

你的HelloActor应该如下所示:

 class HelloActor(): AbstractActor<Any>,Hello 

在kotlin中, Any被映射到java.lang.ObjectAnyRef中的AnyRef ,它们具有相同的功能和用途。 Any地方都可以使用ObjectAnyRef 。 在这里看到更多的kotlin到Java类的映射。

编辑:实际上kotlin更类似于Java,所以你应该遵循Java教程而不是scala。

Interesting Posts