Autumn SALE
Visitor

Visitor in Swift

Visitor is a behavioral design pattern that allows adding new behaviors to existing class hierarchy without altering any existing code.

Read why Visitors can’t be simply replaced with method overloading in our article Visitor and Double Dispatch.

Complexity:

Popularity:

Usage examples: Visitor isn’t a very common pattern because of its complexity and narrow applicability.

The following examples are available on Swift Playgrounds.
Kudos to Alejandro Mohamad for creating the Playground version.

Visitor in Other Languages

Visitor in C# Visitor in C++ Visitor in Go Visitor in Java Visitor in PHP Visitor in Python Visitor in Ruby Visitor in Rust Visitor in TypeScript