---
title: "init(_:_:_:_:otherwise:)"
framework: appintents
role: symbol
role_heading: Initializer
path: "appintents/parametersummarywhencondition/init(_:_:_:_:otherwise:)-8d14d"
---

# init(_:_:_:_:otherwise:)

Creates a When condition checking if a union value parameter matches any case in a list.

## Declaration

```swift
init<ValueType, Parameter>(_ keyPath: KeyPath<Intent, Parameter>, _ comparisonOperator: OneOfComparisonOperator, _ values: [ValueType.ValueType.Cases], @ParameterSummaryBuilder<Intent> _ when: () -> WhenCondition, @ParameterSummaryBuilder<Intent> otherwise: () -> Otherwise) where ValueType == Parameter.Value, Parameter : AnyIntentValue, ValueType.ValueType : AppUnionValue
```

## Parameters

- `keyPath`: Key path to the union value parameter
- `comparisonOperator`: The comparison operator (.oneOf or .noneOf)
- `values`: The array of union value cases to check against
- `when`: The summary to use when the condition is true
- `otherwise`: The summary to use when the condition is false

## Discussion

Discussion Example: When(\.$reaction, .oneOf, [.text, .emoji]) {     Summary("Text-based reaction") } otherwise: {     Summary("Other reaction type") }
