<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm" -->

---
title: Using Swift’s ‘some’ keyword beyond SwiftUI | daily.dev
description: Explains how Swift's 'some' keyword, commonly associated with SwiftUI view declarations, can be applied more broadly to simplify generic function parameters...
canonical: https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using Swift’s ‘some’ keyword beyond SwiftUI | daily.dev
og:description: Explains how Swift's 'some' keyword, commonly associated with SwiftUI view declarations, can be applied more broadly to simplify generic function parameters...
og:url: https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm
og:image: https://api.daily.dev/og/posts/Y1XqY9RZM.png
og:image:alt: Using Swift’s ‘some’ keyword beyond SwiftUI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Swift’s ‘some’ keyword beyond SwiftUI

**[Swift by Sundell](https://daily.dev/sources/swiftbysundell)** · 7 min read · 0 upvotes · 0 comments

## Summary

Explains how Swift's 'some' keyword, commonly associated with SwiftUI view declarations, can be applied more broadly to simplify generic function parameters and to avoid type erasure or boxing in custom protocols. Walks through examples like making a database save function generic over Sequence, and replacing an AnyOperation type-erasing wrapper with 'some Operation' to keep APIs clean without runtime overhead, contrasting this with the 'any' keyword's existential boxing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.swiftbysundell.com/articles/using-swifts-some-keyword-beyond-swiftui>

## Questions this post answers

### How can I use Swift's some keyword to avoid type erasure with a custom protocol like Operation?

Instead of creating an AnyOperation wrapper that boxes the underlying implementation via a closure, a function can return 'some Operation<Data>' directly. This lets the concrete private type be returned without exposing it publicly, resolved at compile time with no runtime overhead, unlike the 'any' keyword which requires boxing into an existential resolved at runtime.

_daily.dev surfaces practical Swift generics patterns like this for developers designing clean API boundaries._

### What is the difference between using some and any with a Swift protocol that has a primary associated type?

The some keyword resolves the underlying concrete type at compile time with no runtime overhead, while any boxes the value into an existential that must be unboxed and resolved at runtime. Both let a generic protocol be referenced as a type, but some avoids the performance cost that any introduces, making it preferable for return types of protocols like Operation<Output>.

_Developers weighing some versus any in Swift APIs can find comparisons like this on daily.dev._

### How do I write a generic function that accepts any Sequence of a specific element type in Swift?

A function parameter can be declared as 'some Sequence<Video>' instead of using a full generic clause like '<T: Sequence>(_ videos: T) where T.Element == Video'. This works because Sequence marks its associated Element type as a primary associated type, letting the protocol be referenced directly as a type while still avoiding type erasure or runtime overhead.

_daily.dev helps Swift developers keep up with syntax simplifications like this for generic APIs._

## Similar posts on daily.dev

- [Existential any in Swift, and when it becomes required](https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl) · Sarunw · 1 upvotes · 1 comments
- [Swift Internals: Why any Protocol Can Be Slower Than Generics](https://daily.dev/posts/swift-internals-why-any-protocol-can-be-slower-than-generics-xmnlfjdqp) · Medium · 0 upvotes · 0 comments
- [Just a Few Keystrokes -- Fatbobman's Swift Weekly \#151](https://daily.dev/posts/just-a-few-keystrokes----fatbobman-s-swift-weekly-151-slajtgpn2) · Fatbobman · 0 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using Swift’s ‘some’ keyword beyond SwiftUI","url":"https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm"},"datePublished":"2026-09-30T11:24:38.992Z","dateModified":"2026-09-30T11:24:59.697Z","description":"Explains how Swift's 'some' keyword, commonly associated with SwiftUI view declarations, can be applied more broadly to simplify generic function parameters...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3a8399451e7bfda5d55fe84fbf8db1b3?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3a8399451e7bfda5d55fe84fbf8db1b3?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Swift by Sundell","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Swift by Sundell","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/42173ef29edf4b928c02307e3051f0d7","url":"https://daily.dev/sources/swiftbysundell"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,swiftui","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Swift by Sundell","item":"https://daily.dev/sources/swiftbysundell"},{"@type":"ListItem","position":3,"name":"Using Swift’s ‘some’ keyword beyond SwiftUI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm#faq","mainEntity":[{"@type":"Question","name":"How can I use Swift's some keyword to avoid type erasure with a custom protocol like Operation?","acceptedAnswer":{"@type":"Answer","text":"Instead of creating an AnyOperation wrapper that boxes the underlying implementation via a closure, a function can return 'some Operation<Data>' directly. This lets the concrete private type be returned without exposing it publicly, resolved at compile time with no runtime overhead, unlike the 'any' keyword which requires boxing into an existential resolved at runtime. daily.dev surfaces practical Swift generics patterns like this for developers designing clean API boundaries."}},{"@type":"Question","name":"What is the difference between using some and any with a Swift protocol that has a primary associated type?","acceptedAnswer":{"@type":"Answer","text":"The some keyword resolves the underlying concrete type at compile time with no runtime overhead, while any boxes the value into an existential that must be unboxed and resolved at runtime. Both let a generic protocol be referenced as a type, but some avoids the performance cost that any introduces, making it preferable for return types of protocols like Operation<Output>. Developers weighing some versus any in Swift APIs can find comparisons like this on daily.dev."}},{"@type":"Question","name":"How do I write a generic function that accepts any Sequence of a specific element type in Swift?","acceptedAnswer":{"@type":"Answer","text":"A function parameter can be declared as 'some Sequence<Video>' instead of using a full generic clause like '<T: Sequence>(_ videos: T) where T.Element == Video'. This works because Sequence marks its associated Element type as a primary associated type, letting the protocol be referenced directly as a type while still avoiding type erasure or runtime overhead. daily.dev helps Swift developers keep up with syntax simplifications like this for generic APIs."}}]}
```

