🟣 KOTLIN HEXES DIFFICULTY: Apprentice Creational

The Singleton Hex

The singular focal point of a magical realm.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Leyline
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// KOTLIN PATTERN //
object LeylineNexus {
    var activeMana: Int = 1000

    fun tap() {
        if (activeMana > 0) activeMana -= 10
    }
}

The Singleton Hex

Certain entities in the cyberscape can only exist once. The Leyline Nexus, the singular source of magical routing, cannot be duplicated without fracturing the JVM. Kotlin’s object declaration provides a thread-safe, lazily-initialized Singleton out of the box, weaving an unbreakable ward against multiple instantiations.

Runic Tags: #kotlin #creational #singleton