---
title: CollectionOfOne
framework: swift
role: symbol
role_heading: Structure
path: swift/collectionofone
---

# CollectionOfOne

A collection containing a single element.

## Declaration

```swift
@frozen struct CollectionOfOne<Element>
```

## Overview

Overview You can use a CollectionOfOne instance when you need to efficiently represent a single value as a collection. For example, you can add a single element to an array by using a CollectionOfOne instance with the concatenation operator (+): let a = [1, 2, 3, 4] let toAdd = 100 let b = a + CollectionOfOne(toAdd) // b == [1, 2, 3, 4, 100]

## Topics

### Initializers

- [init(_:)](swift/collectionofone/init(_:).md)

### Instance Properties

- [mutableSpan](swift/collectionofone/mutablespan.md)
- [span](swift/collectionofone/span.md)

### Instance Methods

- [withBytes(_:)](swift/collectionofone/withbytes(_:).md)

### Default Implementations

- [BidirectionalCollection Implementations](swift/collectionofone/bidirectionalcollection-implementations.md)
- [Collection Implementations](swift/collectionofone/collection-implementations.md)
- [CustomDebugStringConvertible Implementations](swift/collectionofone/customdebugstringconvertible-implementations.md)
- [CustomReflectable Implementations](swift/collectionofone/customreflectable-implementations.md)
- [Equatable Implementations](swift/collectionofone/equatable-implementations.md)
- [Hashable Implementations](swift/collectionofone/hashable-implementations.md)
- [MutableCollection Implementations](swift/collectionofone/mutablecollection-implementations.md)
- [RandomAccessCollection Implementations](swift/collectionofone/randomaccesscollection-implementations.md)
- [Sequence Implementations](swift/collectionofone/sequence-implementations.md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [ContiguousBytes](foundation/contiguousbytes.md)
- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomReflectable](swift/customreflectable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [MutableCollection](swift/mutablecollection.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### Special-Use Collections

- [repeatElement(_:count:)](swift/repeatelement(_:count:).md)
- [EmptyCollection](swift/emptycollection.md)
- [KeyValuePairs](swift/keyvaluepairs.md)
- [DictionaryLiteral](swift/dictionaryliteral.md)
