Type Safely

Type Safely

Call Instances of Any Type Like a Function With @dynamicCallable

Daily Coding Tip 179

Millie Sturgeon's avatar
Millie Sturgeon
Sep 20, 2022
∙ Paid
minimalist photography of three crank phones
Photo by Pavan Trikutam on Unsplash

There are a lot of instances of calling types as functions in SwiftUI.

When the DismissAction environment object is obtained using @Environment(\.dismiss) var dismiss, it is not a function. It is actually a type that implements a function called callAsFunction. The Swift compiler will take any function with this name, w…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture