<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabularData",
  "identifier" : "/documentation/TabularData/AnyColumn",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData9AnyColumnV"
  },
  "title" : "AnyColumn"
}
-->

# AnyColumn

A type-erased column.

```
struct AnyColumn
```

## Overview

`AnyColumn` is a column type that conceals the type of its elements,
unlike [`Column`](/documentation/TabularData/Column), its typed counterpart.

## Topics

### Inspecting a Type-Erased Column

[`var name: String`](/documentation/TabularData/AnyColumn/name)

The name of the column.

[`var count: Int`](/documentation/TabularData/AnyColumn/count)

The number of elements in the column.

[`var missingCount: Int`](/documentation/TabularData/AnyColumn/missingCount)

The number of missing elements in the column.

[`var wrappedElementType: any Any.Type`](/documentation/TabularData/AnyColumn/wrappedElementType)

The underlying type of the column’s elements.

[`func isNil(at: Int) -> Bool`](/documentation/TabularData/AnyColumn/isNil(at:))

Returns a Boolean that indicates whether the element at the index is missing.

### Creating a Column of the Same Type

[`var prototype: any AnyColumnPrototype`](/documentation/TabularData/AnyColumn/prototype)

A prototype that creates type-erased columns with the same underlying type as the column slice.

### Creating a Typed Column

[`func assumingType<T>(T.Type) -> Column<T>`](/documentation/TabularData/AnyColumn/assumingType(_:))

Returns the underlying typed column.

### Adding Elements

[`func append(Any?)`](/documentation/TabularData/AnyColumn/append(_:))

Appends an optional element to the column.

[`func append(contentsOf: AnyColumn)`](/documentation/TabularData/AnyColumn/append(contentsOf:)-2in58)

Appends the contents of another column to the column.

[`func append(contentsOf: AnyColumnSlice)`](/documentation/TabularData/AnyColumn/append(contentsOf:)-az5b)

Appends the contents of a column slice to the column.

### Removing an Element

[`func remove(at: Int)`](/documentation/TabularData/AnyColumn/remove(at:))

Removes an element from the column.

### Accessing Elements

[`subscript(Int) -> Any?`](/documentation/TabularData/AnyColumn/subscript(_:)-6z1b5)

Accesses an element at an index.

[`subscript(Range<Int>) -> AnyColumnSlice`](/documentation/TabularData/AnyColumn/subscript(_:)-1n9t9)

Accesses a contiguous subrange of the elements.

### Creating a Slice of Unique Elements

[`func distinct() -> AnyColumnSlice`](/documentation/TabularData/AnyColumn/distinct())

Generates a column slice that contains unique elements.

### Creating a Slice by Masking Elements

[`subscript<C>(C) -> AnyColumnSlice`](/documentation/TabularData/AnyColumn/subscript(_:)-3658g)

Returns a slice of the column by selecting elements with a collection of Booleans.

### Encoding a Column

[`func encode<T, Encoder>(T.Type, using: Encoder) throws`](/documentation/TabularData/AnyColumn/encode(_:using:))

Encodes each element of the column.

[`func encoded<T, Encoder>(T.Type, using: Encoder) throws -> AnyColumn`](/documentation/TabularData/AnyColumn/encoded(_:using:))

Generates a column by encoding each element’s value.

### Decoding a Column

[`func decode<T, Decoder>(T.Type, using: Decoder) throws`](/documentation/TabularData/AnyColumn/decode(_:using:))

Decodes the data in each element of the column.

[`func decoded<T, Decoder>(T.Type, using: Decoder) throws -> AnyColumn`](/documentation/TabularData/AnyColumn/decoded(_:using:))

Decodes data for each element of the column.

### Describing a Column

[`var description: String`](/documentation/TabularData/AnyColumn/description)

A text representation of the column.

[`var debugDescription: String`](/documentation/TabularData/AnyColumn/debugDescription)

A text representation of the column suitable for debugging.

[`var customMirror: Mirror`](/documentation/TabularData/AnyColumn/customMirror)

A mirror that reflects the column.

### Comparing Two Columns

[`static func == (AnyColumn, AnyColumn) -> Bool`](/documentation/TabularData/AnyColumn/==(_:_:))

Returns a Boolean that indicates whether the columns are equal.

### Hashing a Column

[`func hash(into: inout Hasher)`](/documentation/TabularData/AnyColumn/hash(into:))

Hashes the essential components of the column by feeding them into a hasher.

### Supporting Types

### Invoking Protocol Methods

  <doc:API-Sequence--AnyColumn>

  <doc:API-Collection--AnyColumn>

  <doc:API-Bidirectional-Collection--AnyColumn>

  <doc:API-Random-Access-Collection--AnyColumn>

### Default Implementations

[CustomDebugStringConvertible Implementations](/documentation/TabularData/AnyColumn/CustomDebugStringConvertible-Implementations)

[CustomReflectable Implementations](/documentation/TabularData/AnyColumn/CustomReflectable-Implementations)

[CustomStringConvertible Implementations](/documentation/TabularData/AnyColumn/CustomStringConvertible-Implementations)

[Equatable Implementations](/documentation/TabularData/AnyColumn/Equatable-Implementations)

[Hashable Implementations](/documentation/TabularData/AnyColumn/Hashable-Implementations)

[RandomAccessCollection Implementations](/documentation/TabularData/AnyColumn/RandomAccessCollection-Implementations)

## Relationships

### Conforms To

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`Escapable`](/documentation/Swift/Escapable)

[`MutableCollection`](/documentation/Swift/MutableCollection)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`RandomAccessCollection`](/documentation/Swift/RandomAccessCollection)

[`Collection`](/documentation/Swift/Collection)

[`Sequence`](/documentation/Swift/Sequence)

[`CustomReflectable`](/documentation/Swift/CustomReflectable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Copyable`](/documentation/Swift/Copyable)

[`AnyColumnProtocol`](/documentation/TabularData/AnyColumnProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)