class Repository private constructor() {
companion object {
val instance: Repository by lazy {
Repository()
}
}
}
详细解释:
https://medium.com/@BladeCoder/kotlin-singletons-with-argument-194ef06edd9e
class Repository private constructor() {
companion object {
val instance: Repository by lazy {
Repository()
}
}
}
详细解释:
https://medium.com/@BladeCoder/kotlin-singletons-with-argument-194ef06edd9e
本文标题:[WIP]Kotlin怎么生成singleton
本文链接:https://www.haomeiwen.com/subject/lomvuftx.html
网友评论