在Kotlin中,如何仅通过特定类型访问属性 [英] In Kotlin, how to make a property accessible by only specific type
本文介绍了在Kotlin中,如何仅通过特定类型访问属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我有一个类似的Kotlin课:
Lets say I have a Kotlin class similar to this:
class MyKotlinExample {
val mMyString = MutableLiveData<String>()
}
MutableLiveData
扩展了LiveData
,但是我不想将MutableLiveData
公开给其他类.他们只能将/c作为我的特殊String
MutableLiveData
extends LiveData
however I don't want to expose MutableLiveData
to other classes. They should only see/access LiveData<String>
as my special String
有可能,和/或好的/建议的?
Is it possible, and/or good/advised etc?
推荐答案
查看全文