Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Call Instances of Any Type Like a Function With @dynamicCallable

Call Instances of Any Type Like a Function With @dynamicCallable

Daily Coding Tip 179

Millie Sturgeon's avatar
Millie Sturgeon
Sep 20, 2022
∙ Paid

Share this post

Type Safely
Type Safely
Call Instances of Any Type Like a Function With @dynamicCallable
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share