https://kotlinlang.org logo
#codereview
Title
# codereview
s

Sudhir Singh Khanger

09/25/2018, 4:59 PM
Copy code
class CustomApplication: Application() {

    companion object {
        private var INSTANCE: CustomApplication? = null

        @JvmStatic
        fun get(): CustomApplication = INSTANCE!!
    }

    override fun onCreate() {
        super.onCreate()
        INSTANCE = this
    }
}
Or
Copy code
class CustomApplication : Application() {

    companion object {
        lateinit var instance: CustomApplication
            private set
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
    }
}
Not sure if this is more appropriate for #android. Which one would you prefer for creating an Android Application class? And why?
2️⃣ 4
🤯 1
e

edwardwongtl

09/26/2018, 4:32 AM
Prefer 2️⃣ to avoid Nullable types in Kotlin world.
✔️ 1
5 Views