Kotlin Generic Property

后端 未结 4 1132
無奈伤痛
無奈伤痛 2020-12-06 21:45

Is there a way in kotlin to create a generic property without declaring a class level generic type? Something that looks like this:

interfac         


        
4条回答
  •  温柔的废话
    2020-12-06 22:11

    No, how should the compiler know what T is? If you don't need the generic type parameter T anyway, you can just declare it as val t: Any.

提交回复
热议问题