小编beg*_*ner的帖子

如何在 Kotlin 中使用内部构造函数实例化类

我有兴趣从kotlin 提供的包中实例化Duration类。Kotlin.time

到目前为止我的代码..

...

import kotlin.time

class MyGLRenderer : GLSurfaceView.Renderer {
      override fun onSurfaceCreated(unused: GL10, config: EGLConfig) {
           var tp0:Duration= Duration(10L)
           //cannot acces `<init>:` it is internal in `Duration`          }
      override fun onDrawFrame(unused: GL10) {}
      override fun onSurfaceChanged(unused: GL10, width: Int, height: Int) {}
}
Run Code Online (Sandbox Code Playgroud)

那么我该如何实现这个意图呢?

我也尝试过:

var tp0:Duration= Duration(Duration.)
//to find a getter or setter that can be used to pass the required `long` data type to
// the constructor but no function will return long …
Run Code Online (Sandbox Code Playgroud)

time constructor internals game-engine kotlin

0
推荐指数
1
解决办法
375
查看次数

标签 统计

constructor ×1

game-engine ×1

internals ×1

kotlin ×1

time ×1