Skip to content

Instantly share code, notes, and snippets.



Last active Nov 27, 2018
What would you like to do?
Kotlin singleton pattern with class paramters
class Singelton private constructor(context: Context) {
companion object {
private var INSTANCE: Singelton? = null
fun getInstance(context: Context): Singelton =
INSTANCE ?: synchronized(this) {
INSTANCE ?: Singelton(context).also { INSTANCE = it }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.