🕊️ SWIFT ENCHANTMENTS DIFFICULTY: Apprentice Structural

The Adapter Pattern

Translating ancient runic spells into modern protocol-oriented magic.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Linguistics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SWIFT PATTERN //
protocol ModernSpell {
    func executeSpell()
}
class AncientRune {
    func invokeRune() { print("Invoking ancient power") }
}
class RuneAdapter: ModernSpell {
    private let rune: AncientRune
    init(rune: AncientRune) { self.rune = rune }
    func executeSpell() { rune.invokeRune() }
}

The Adapter: Bridging the Eras

The Adapter acts as a magical translator, wrapping an AncientRune so it can be invoked via the ModernSpell protocol.

Runic Tags: #swift #design-pattern #structural