DEV Community

Discussion on: Head First Design Pattern: 4 of 10

Collapse
sanmiade profile image
Oluwasanmi Aderibigbe Author • Edited

Oh, That's very weird. I don't know anything about Selenium. I've always used the object keyword whenever I need to use the Singleton pattern but you can try this. It should work.

fun main() {
    val signleton = ManualSignleton.getInstance()
}

class ManualSignleton {
    private constructor()

    companion object {
        @Volatile
        private var INSTANCE: ManualSignleton? = null

        fun getInstance(): ManualSignleton {
            return INSTANCE ?: synchronized(this) {
                val newInstance = ManualSignleton()
                INSTANCE = newInstance
                newInstance
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Let me know if it does

Collapse
ddaypunk profile image
Andy Delso

If and when I get back to the project, I can try it! Thanks!