[WIP]Kotlin怎么生成singleton
2018-07-06 本文已影响8人
假装在去天使之城的路上
class Repository private constructor() {
companion object {
val instance: Repository by lazy {
Repository()
}
}
}
详细解释:
https://medium.com/@BladeCoder/kotlin-singletons-with-argument-194ef06edd9e