如何将Class #cast方法从Java转换为Kotlin?

我想从Java转换下面的代码:

Object from = ... Class toClass = ... T result = toClass.cast(from); 

到Kotlin:

 Any? from = ... KClass toClass = ... T result = // toClass.cast(from) - how to convert this line to Kotlin? 

怎么做?

您可以使用java属性访问Class实例

这应该工作: toClass.java.cast(from)

对于任何Java到Kotlin转换器,使用网站上提供的在线转换器。

http://try.kotlinlang.org/#/Examples/Longer%20examples/Maze/Maze.kt