Double Dispatch: Prelude to the Visitor Pattern

Опубликовано: 23 Март 2026
на канале: Dave Leeds
4,359
232

One reason the Visitor Pattern can feel confusing is because of double dispatch. So before we dive into the Visitor Pattern itself, let’s take a closer look at double dispatch—what it is, how it’s traditionally handled in single-dispatch languages, and how a few Kotlin language features can make it much simpler.

📘 My book, Kotlin: An Illustrated Guide is now available in paperback!
https://www.amazon.com/Kotlin-Illustr...

✨ New to Kotlin? Start your journey here: https://typealias.com/start/

🚀 Get the inside scoop on everything I'm working on - join my new email newsletter!
Sign up here: https://newsletter.typealias.com/

👨🏽‍💻 Source code for today's video:
https://github.com/typealias-studios/...

📚 Chapters
00:00 Introduction
00:36 Dispatch and Multiple Dispatch
04:38 Simulating Double Dispatch in Kotlin
08:01 A Simpler Approach
09:48 Wrap-up