Last active
February 19, 2023 21:45
-
-
Save humbleshuttler/c515dcf968c8b66601ed182b429198e3 to your computer and use it in GitHub Desktop.
Singleton in kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object DatabaseSingleton { | |
private var isConnected: Boolean = false | |
init { | |
println("Connecting to database...") | |
isConnected = true | |
} | |
fun database(): DatabaseSingleton { | |
return this | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment