We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f973031 commit ce57bcaCopy full SHA for ce57bca
src/main/kotlin/Singleton.kt
@@ -1,15 +1,13 @@
1
-class PrinterDriver() {
2
- fun print() = println("Printing with object: $this")
3
-
4
- companion object {
5
- val instance: PrinterDriver by lazy {
6
- PrinterDriver().apply { println("Initializing with object: $this") }
7
- }
+object PrinterDriver {
+ init {
+ println("Initializing with object: $this")
8
}
+
+ fun print() = println("Printing with object: $this")
9
10
11
fun main(args: Array<String>) {
12
println("Start")
13
- PrinterDriver.instance.print()
14
15
-}
+ PrinterDriver.print()
+}
0 commit comments