Opaque and Boxed Protocol Types | Documentation
Swift provides two ways to hide details about a value’s type: opaque types and boxed protocol types. Hiding type information is useful at boundaries between a module and code that calls into the module, because the underlying type of the return value can remain private. A function or method that returns an opaque type hides its return value’s type information. Instead of providing a concrete type as the function’s return type, the return value is described in terms of the protocols it supports. Opaque types preserve type identity — the compiler has access to the type information, but clients of the module don’t. A boxed protocol type can store an instance of any type that conforms to the given protocol. Boxed protocol types don’t preserve type identity — the value’s specific type isn’t known until runtime, and it can change over time as different values are stored. For example, suppose you’re writing a module that draws ASCII art shapes. The basic characteristic of an ASCII art shape i
To navigate the symbols, press Up Arrow, Down Arrow, Left Arrow or Right Arrow No items were found 1 item was found {number} items were found. Tab back to navigate through them. re looking for can't be found."},"color-scheme":{"select":"Select a color scheme preference","auto":"Auto","dark":"Dark","light":"Light"},"accessibility":{"strike":{"start":"start of stricken text","end":"end of stricken text"},"code":{"start":"start of code block","end":"end of code block"},"skip-navigation":"Skip Navigation","in-page-link":"in page link"},"select-language":"Select the language for this page","icons":
Explore this link on the map →related reading
- Swift Protocol 背后的故事(Swift 5.6/5.7) | 雪峰的blogzxfcumtcs.github.io
- Swift: From Protocol to AssociatedType then Type Erasure | Welcome to Monstarlab’s Engineering Blogengineering.monstar-lab.com
- Documentationdocs.swift.org
- Typst: About usweb.archive.org
- Protocollie Claude Code Vibe Coding setup · GitHubgist.github.com
- Observable | Apple Developer Documentationdeveloper.apple.com
- ObservableObject | Apple Developer Documentationdeveloper.apple.com
- Typescript utility types that you must know - DEV Communitydev.to
- SOOTplay.soot.com
- GitHub - darrylmorley/whatcable: macOS menu bar app that tells you, in plain English, what each USB-C cable plugged into your Mac can actually do · GitHubgithub.com
- What Every Programmer Should Know About Memoryakkadia.org
- Pipedpiped.kavin.rocks