<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/OptionalUnwrapper",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents17OptionalUnwrapperV"
  },
  "title" : "OptionalUnwrapper"
}
-->

# OptionalUnwrapper

A transformer that unwraps optional elements and throws when encountering missing values.

```
struct OptionalUnwrapper<Element>
```

## Topics

### Creating a transformer

[`init()`](/documentation/CreateMLComponents/OptionalUnwrapper/init())

Creates a transformer that unwraps an optional element or throws if the value is nil.

### Performing the transformation

[`func applied(to: Element?, eventHandler: EventHandler?) throws -> Element`](/documentation/CreateMLComponents/OptionalUnwrapper/applied(to:eventHandler:))

Unwraps an optional element or throws if the value is `nil`.

## Relationships

### Conforms To

[`Transformer`](/documentation/CreateMLComponents/Transformer)

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

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

---

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)