<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/type-casting-and-existential-types",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Type Casting and Existential Types"
}
-->

# Type Casting and Existential Types

Perform casts between types or represent values of any type.

## Topics

### Integer Value Casting

[`numericCast(_:)`](/documentation/Swift/numericCast(_:))

Returns the given integer as the equivalent value in a different integer
type.

### Closure Casting

[`withoutActuallyEscaping(_:do:)`](/documentation/Swift/withoutActuallyEscaping(_:do:))

Allows a nonescaping closure to temporarily be used as if it were allowed
to escape.

### Instance Casting

[`unsafeDowncast(_:to:)`](/documentation/Swift/unsafeDowncast(_:to:))

Returns the given instance cast unconditionally to the specified type.

[`unsafeBitCast(_:to:)`](/documentation/Swift/unsafeBitCast(_:to:))

Returns the bits of the given instance, interpreted as having the specified
type.

### Existential Types

Use a variable or constant with an existential type to hold an instance of any type.

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

The protocol to which all classes implicitly conform.

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

The protocol to which all class types implicitly conform.

### Comparing Identity

[`===(_:_:)`](/documentation/Swift/===(_:_:))

[`!==(_:_:)`](/documentation/Swift/!==(_:_:))

Returns a Boolean value indicating whether two references point to
different object instances.

### Void Type

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

The return type of functions that don’t explicitly specify a return type,
that is, an empty tuple `()`.



---

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)