How can I make this singleton simpler in Kotlin?
Clash Royale CLAN TAG #URR8PPP How can I make this singleton simpler in Kotlin? How can I make this singleton simpler in Kotlin for the Android room database initialization? @Database(entities = arrayOf(Book::class, User::class), version = 1) abstract class AppDatabase : RoomDatabase() { abstract fun bookModel() : BookDao abstract fun userModel() : UserDao companion object { private var INSTANCE: AppDatabase? = null fun getInMemoryDatabase(context: Context): AppDatabase { if (INSTANCE == null) { INSTANCE = Room.inMemoryDatabaseBuilder(context.applicationContext, AppDatabase::class.java).build() } return INSTANCE!! } fun destroyInstance() { INSTANCE = null } } } I had the same issue few days ago. – Abner Escócio 13 hours ago ...