---
title: "as(_:)"
framework: appintentstesting
role: symbol
role_heading: Instance Method
path: "appintentstesting/anyappenum/as(_:)"
---

# as(_:)

Casts the raw value to the specified type.

## Declaration

```swift
func `as`<T>(_ type: T.Type) throws -> T where T : LosslessStringConvertible
```

## Discussion

Discussion If the raw value isn’t an instance of that type, this method throws an error. let enumCase = MyEnumDefinition.makeCase("caseName")

try enumCase.as(String.self) == "caseName" note: If the raw value cannot be represented as the target type.
