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

# as(_:)

Casts the value to the given type.

## Declaration

```swift
func `as`<IntentType>(_ type: IntentType) throws -> IntentType.Instance where IntentType : AppIntentTypeDefinition
```

## Discussion

Discussion If the value’s type doesn’t match, this method throws an error. let CoffeeEntity = definitions.entities["CoffeeEntity"] let coffee: AnyAppEntity = try result.value.as(CoffeeEntity)
